Forum

Talking Thermometer with Foxonix and Arduino

More
2 years 3 months ago #600 by wsakran
wsakran created the topic: Talking Thermometer with Foxonix and Arduino
This project is a talking thermometer which uses an Arduino to read an analog temperature sensor and a Fox Board to say the temperature. Audio is included in the project to cover temperatures from 40 degrees F to 109 degrees F. You could also record your own audio so that the thermometer speaks with your own voice. Note that if you do not have a temperature sensor, you can use the sensor that is internal to the Arduino chip, but it's pretty inaccurate. There is a setting in the Arduino program to select between the internal and external temperature sensor.

The Arduino reads the voltage from the temperature sensor and converts that voltage to a value representing the temperature. It then generates a tens place value and a ones place value for the temperature. These two values are output to the Fox board. When the values are ready, a read signal is asserted. The Fox board then reads these two values and decodes them, assembling the required audio phrases in the proper order. For example:
"The temperature is" + "seventy" + "four" + "degrees"

This is a great example of how audio can be concatenated in a Foxonix program.

All source files required for this project are in the attached ZIP file. The hardware hook-up diagram is also included for reference. The Arduino can be hooked up directly to a Fox Board as shown in the diagram. Note that the Fox Board is powered by the Ardunio and that the EXT/USB jumper must be removed from the Fox Board. You could also hook up your Arduino to a Project Board that has been programmed with the program BIN file. Yet another option is to use the Arduino Shield so that you don't have to wire up anything manually. (In this case the Arudino Shield would plug into the Arduino and the programmed Project Board plugs into the shield.)

Please let me know any comments or questions.
Attachments:
The following user(s) said Thank You: ericleven

Please Log in or Create an account to join the conversation.

More
2 years 3 months ago - 2 years 3 months ago #601 by ericleven
ericleven replied the topic: Talking Thermometer with Foxonix and Arduino
Thanks for this example; it's awesome and opens lots of doorways to using Arduino and Foxonix together.

I realize this is a community forum geared towards Foxonix, but as a non-engineer who hasn't learned about port manipulation or bitwise math, I have a couple questions; I hope someone can help ( I realize that someone will most likely be Will, who's been so helpful. I apologize in advance!).

1) How is M1 decoding the "tens" bits? Does the script automatically map the binary number to the corresponding element in the array?

2) Is there another (higher level) way to send data from Arduino ports to Foxonix ports without using fancy port manipulation or bitwise operations?

3) Why do you need to clear the bits in the Arduino ports before you write to them? And why do they need to be cleared in hexadecimal notation?

4) Just curious; how would you change this if you needed to measure temperatures in the thousands (necessitating more than four bits of data for tens)? The Arduino is out of usable pins to send another four bits worth of data, no?

Thanks!
Last Edit: 2 years 3 months ago by ericleven.

Please Log in or Create an account to join the conversation.

More
2 years 3 months ago #602 by foxonix
foxonix replied the topic: Talking Thermometer with Foxonix and Arduino
Hey Eric:

1.) You've pretty much got it right. The label that gets called is determined by the value of M1. If M1=0, then the "zeroth" element of the array gets called. If M1=1, then the first element of the array gets called. And so on. This type of jump based on register value is described here .

2.) I'm not sure offhand if there is a higher level way to write data to a port on an Arduino. The digital write command is geared toward writing to a single pin. In order to write to the port (or a group of pins) all at once you need to do some lower level port manipulation. One option might be to extract one bit at time from your variable and write to output pins individually. That is, you could extract bit0 from your variable and write it to pin0, then extract bit1 and write it to pin1, and so on. This could be done at a higher level, I think.

3.) In the Arduino code, the reason we clear the bits before writing to them has to do with the way the values are written to the pins. Let's look at how we write the tens value to Port B as an example. Since we are only using the lower four bits on port B we don't want to write to the whole port all at one. Doing so would clobber the upper four bits that might be used for something somewhere else in the program. So instead of writing the whole port all at once, we use a bitwise AND to clear the lower four bits.
PORTB &= 0xF0;          // clear the lower four bits of Port B
ANDing the port with hex value F0 (same as binary 11110000) forces the lower four bits to zero. We then do a bitwise OR to write the tens value to the lower four bits:
PORTB |= tens;          // write the tens values to Port B
The bitwise OR sets the individual bits in the port to match the bits in the tens variable. So, for example, if tens is equal to 9 (binary 1001), then the lower for bits of the port get set to 1001.

4.) To register a different temperature range, you would need a sensor to measure that range and you might need to scale the reading differently. Right now this example project uses a total of eight bits to relay the temperature, for a total of 256 combinations. This example project is essentially arranged to register temperatures from 0 to 109 degrees (in steps of 1 degree). You could just as well register temperatures in a different range and scale, for example 0 to 1000 (in steps of 10).

Foxonix - make your ideas heard.
@foxonixdev

Please Log in or Create an account to join the conversation.

More
2 years 3 months ago #603 by ericleven
ericleven replied the topic: Talking Thermometer with Foxonix and Arduino
Thanks so much for all the answers. It's all super helpful and you're definitely going above and beyond!

Please Log in or Create an account to join the conversation.

Time to create page: 0.239 seconds