I recently bought an Arduino Uno to use as an interface between a PC and a radio-control transmitter. The idea is that the PC will send data to the Arduino and it will use that data to create a PPM signal for input to the transmitter (instead of using joysticks).
The serial library makes communication with the PC easy but I haven't been able to find any information on how much CPU time it uses.
Also, I don't know whether Serial uses interrupts and, if so, whether those interrupts might upset the timing of my PPM signal which I envisage will be determined by timer1 interrupts.
Perhaps someone can provide information or point me to references.
Yes serial reciption is done using interrupts. Timer 1 is used to control two of the PWM pins. However as PWM is done in the hardware it is not affected by interrupts.
I would have thought your biggest source of delay would be getting your PC to send the data because that is a multitasking system and can go walkabout, especially if it is running Linux.
Thanks Mike for the quick response.
I'm not clear from your reply if the Serial library uses Timer1 - if it does that's a deal-breaker because I need the 16-bit timer to get the range of pulses to control the transmitter.
Also I need to use PPM and not PWM. With PPM each pulse has a different width that represents an analogue value for a particular transmitter channel - 7 channels would need 7 pulses each of a different width which are then repeated after a delay which is longer than the longest possible pulse.
Do you have any information about how much Arduino CPU time the serial library uses?
I am not concerned about Linux delays because the Arduino will act as an intermediary using the most recent data it has.
However I do want the Arduino to have time to do other stuff such as reporting the status of I/O pins to the PC and, perhaps, intermittently controlling a few servos. The servo will only need to be controlled when it needs to change position.
...R
Grumpy_Mike:
Yes serial reciption is done using interrupts. Timer 1 is used to control two of the PWM pins. However as PWM is done in the hardware it is not affected by interrupts.
I would have thought your biggest source of delay would be getting your PC to send the data because that is a multitasking system and can go walkabout, especially if it is running Linux.
I'm not clear from your reply if the Serial library uses Timer1
It does not use the timer interrupt. It uses the interrupt from the UART.
So it might be that the interrupts are disabled for a short time while data is being recieved. I have no data on this but the delay in time is not significant unless your PPM system requires 100% of the CPU time.