I'm a mechanical engineer with good experience in programming in C/C++, Java, C# etc. I have dabbled in hobby electronics, but I have never dealt with Microcontrollers.
I'm thinking of making a prototype for a handheld device, with a touchscreen interface. I thought of using Arduino after seeing this
touchscreen:
{hmmm I cant post the link because this is my first post... I will post it later}
Here's what the device will be doing:
Interface with a RFID reader module, (these things have a simple serial TX and RX pin interface) and probe every second or so for a read.
If the RFID module reads a tag, display some options on the touch screen and wait for user input.
Based on the reader input, do certain actions, like shut off the RFID
module, do a visual warning through an LED, or an audio warning through a piezo speaker/buzzer of some sort.
Interface an accelerometer and do certain actions based on motion.
My question is: Is this possible using an Arduino board? I read the documentation and saw the loop() function. All this continuous monitoring of the pins and sending has to be done through the loop()
function, right? Can it multitask several things like these?
Any help or pointing in the right direction will be greatly appreciated.
Using an RFID reader on an Arduino that wants to be doing something else presents some issue. If the RFID reader is connected to the TX/RX pins, so that Serial.available() works, it interferes with uploading sketches to the Arduino.
If it's connected to other pins, using software serial means, the speed may not be fast enough to capture the data, and not all the software serial options implement the Serial.available function.
Touch screens and lcd can use up a bunch of the Arduino I/O pins, leaving few free for other purposes.
Why would you want to shut off the RFID reader?
Multi-tasking has many definitions. There is no threading model on the Arduino. That is, several processes can not be running simultaneously. However, even on a single core CPU on a computer, only one process at a time executes, regardless of whether an application is multi-threaded or not. Use of interrupts makes it possible to not continually ask a sensor or device if it has information of interest. It will butt in when it does.
it interferes with uploading sketches to the Arduino
what are sketches? From the documentaion it sounds like an image you upload to the memory to reduce boot time, am I right?
If it's connected to other pins, using software serial means, the speed may not be fast enough to capture the data, and not all the software serial options implement the Serial.available function.
the baud rate for the RFID reader can vary between 9600 to 115200. I'm okay with 9600, because I'll be making a read every few seconds or so.
Touch screens and lcd can use up a bunch of the Arduino I/O pins, leaving few free for other purposes.
By shut off I meant going to sleep/idle mode to save power. When certain tags are read, I wont need to do reading for a while...
There is no threading model on the Arduino. ...Use of interrupts makes it possible to not continually ask a sensor or device if it has information of interest. It will butt in when it does.
You hit the nail. Threading was exactly what was on my mind. I want to make the UI responsive even if the processor is waiting for some data. I will look into the interrupts.
yea "its a one time deal" as in you load it on the chip once and it stays on there until you overwrite it
but not "its a one time deal" as in if you screw up the sketch you toss the chip in the waste bin, the current storage technology can handle thousands of write cycles before it wears out
but not "its a one time deal" as in if you screw up the sketch you toss the chip in the waste bin, the current storage technology can handle thousands of write cycles before it wears out
And some of us use up a lot of those write cycles trying to get our programs to run correctly.