Hi again, I am having another difficult time finding examples of what I want to achieve with the next stage of this project. I found one or 2 examples on Youtube, but no code to review.
Goal: Output the correct pulse per mile signal to drive a factory speedometer based on current MPH input value that the Arduino has stored.
The MPH input value is read from the engine control module (ECM) canbus (already have sorted out) and is stored as a int.
Sorry for the lack of details. The factory speedometer / Instrument cluster is from a 2006 BMW x5. With coding/programming, I changed the settings from Canbus input to analog input to drive the speedometer. This has been done on one of my other BMW's.
On another engine swap I've done is a 1999 5 series bmw, did the same coding to turn the speedometer to analog input, and wired the speedometer signal from the ECM directly to the cluster connector per wire diagrams and works exactly as it should.
this new project, the ECM (2019 GM Silverado e92a) does not have a MPH output wire, everything is canbus. I am lacking how to make this signal output
Maybe it is different. Using "blink" or "blink without delay" techniques creates the pulses in software. At higher road speeds, the pulses might be produced inaccurately when the code is also performing other tasks such as communicating with the ECM over CANBUS. With careful coding, it might be possible to produce the pulses accurately, I don't know, I'm not very familiar with CANBUS libraries.
Using one of the various tone libraries instead of the built-in tone() function means that the pulses are generated in hardware (and possibly some software in an interrupt routine). This way, producing accurate pulses won't be disturbed by other tasks like reading CANBUS.
The standard built-in arduino tone() function uses one of the 8-bit timers which causes that limitation of 31Hz minimum frequency. But other available tone libraries (tone, toneac...) use, or can use, a 16-bit timer which can produce a wider range of frequencies.