I am currently working on a project which produces a pulsed output based on the speed information from a GPS unit (from TinyGPS).
The pulsed output produced is used to drive a vehicle speedometer, so requires to be a constantly running output.
Ideally, it should also be configurable - so that it can be used in vehicles where speedometers expect different pulses per mile.
As I understand, it would not be possible to run a simple sketch that outputs a variable pulse on a digital I/O Pin based on the speed indicated by the GPS. This is due to the time taken to read the GPS info and calculate the pulse length required, would interrupt the timing of the output and disturb the output on the speedometer.
I've read a little about using PWM instead and manipulating the output frequency using the Timer/Counter Control Registers TCCRnA and TCCRnB, the Output Compare Registers OCRnA and OCRnB, etc.
I'm not sure if I could be trying to do the wrong thing that way? I need the frequency to be variable between at least 57Hz (5mph) and 2050Hz (180mph).
My other 'idea' was to use a PWM output to drive a Voltage to Frequency converter. That might be a little bit 'old school' - but would have the added advantage that an end user could setup the device using a variable resister, rather than configuring the arduino.
I would appreciate any input to the above. Thank you.
As I understand, it would not be possible to run a simple sketch that outputs a variable pulse on a digital I/O Pin based on the speed indicated by the GPS. This is due to the time taken to read the GPS info and calculate the pulse length required, would interrupt the timing of the output and disturb the output on the speedometer.
Only if you're trying to toggle the pin yourself.
jeboa:
I've read a little about using PWM instead and manipulating the output frequency using the Timer/Counter Control Registers TCCRnA and TCCRnB, the Output Compare Registers OCRnA and OCRnB, etc.
I'm not sure if I could be trying to do the wrong thing that way? I need the frequency to be variable between at least 57Hz (5mph) and 2050Hz (180mph).
I'd also like to offer a GPS library I wrote, NeoGPS. It can be configured to parse only the speed, from only the $GPRMC message. This will save lots of RAM, FLASH and processing time.
jeboa:
I've read a little about using PWM instead and manipulating the output frequency using the Timer/Counter Control Registers TCCRnA and TCCRnB, the Output Compare Registers OCRnA and OCRnB, etc.
I'm not sure if I could be trying to do the wrong thing that way? I need the frequency to be variable between at least 57Hz (5mph) and 2050Hz (180mph).
57 Hz and 2050 Hz are both in the audible range, so the easiest way to create a square wave in that frequency range is the tone() function.
Thank you for all the extremely helpful pointers and information. /dev - I will be trying your NeoGPS library and thank you for adding the speed only config - that's a very efficient use of memory and RAM for this purpose.
I'm just waiting for a new GPS module (Ublox Neo-7M) with 10Hz update to arrive before carrying on. Will keep the thread updated with results. The module I am using is configurable in that it can be set to automotive mode - maybe this will compensate for the 45 degree slope? Although I think GPS functionality might be my last thought if I'm descending that kind of slope in my car!!