Page 1 of 1

Driving mechanical speedo from CAN

Posted: Mon May 20, 2024 6:57 am
by ramiroflores
Is it possible to take the rpm CAN message from a motor controller, feed that to some device and then have that device spit out a 0-5v signal?
I want to use that output to control a little DC motor controller to turn a little motor connected to the speedometer cable in my truck.

Re: Driving mechanical speedo from CAN

Posted: Mon May 20, 2024 8:54 am
by johu
Welcome :)

An arduino can hack it. You'd not use 0-5V but rather PWM as that is more common.

When creating new threads use a descriptive title. I've changed it for you

Re: Driving mechanical speedo from CAN

Posted: Mon May 20, 2024 10:13 am
by muehlpower
There are ready-made solutions for 400€ - 600€ from dakota digital or speedhut. An Arduino with a stepper motor should work. The speed could be a problem, as you need up to approx. 3000 rpm.

Re: Driving mechanical speedo from CAN

Posted: Mon May 20, 2024 11:21 am
by Uppertown
muehlpower wrote: Mon May 20, 2024 10:13 am An Arduino with a stepper motor should work. The speed could be a problem, as you need up to approx. 3000 rpm.
This place has a stepper motor that should do;

https://www.omc-stepperonline.com/12v-3 ... ch=42blr53

and a controller for it

https://www.omc-stepperonline.com/digit ... ch=bld-510

Re: Driving mechanical speedo from CAN

Posted: Mon May 20, 2024 11:49 am
by arber333
ramiroflores wrote: Mon May 20, 2024 6:57 am Is it possible to take the rpm CAN message from a motor controller, feed that to some device and then have that device spit out a 0-5v signal?
I want to use that output to control a little DC motor controller to turn a little motor connected to the speedometer cable in my truck.
Why not use the speedo internal drive lines to drive the speedo from PWM directly. When you get CAN signal you process this to calculate vehicle speed. This depends on RPM and wheel size.
Sample for my Teensy VCU code:

Code: Select all

void Speedo()
{
//if (timer100_4.check() == 1)
 // {  
calcspeed = (motorRPM / ratio) * tireD * 3.14 * 60 / 1000; // speed = wheelsRPM * tireD * PI * 60 / 1000 Km/h
calcHz = calcspeed * 1.4; // correction factor
if (calcHz >= 0) {
calcHzi = calcHz;
}
else { //the same in reverse
calcHzi = calcHz * (-1);
}
tone(OUT7, calcHzi); // function to move the dial
//analogWriteFrequency(OUT7, calcHzi);
// }
}
I then create another function which will drive transistor to move the needle. My dash speedo will move in response to variable frequency. This is harder to reach than simply command variable PWM at fixed frequency like RPM dials.

Re: Driving mechanical speedo from CAN

Posted: Mon May 20, 2024 12:19 pm
by Uppertown
arber333 wrote: Mon May 20, 2024 11:49 am Why not use the speedo internal drive lines to drive the speedo from PWM directly.
I'm guessing the OP has a cable driven mechanical speedo rather than an electronic one?

Re: Driving mechanical speedo from CAN

Posted: Mon May 20, 2024 4:07 pm
by arber333
Uppertown wrote: Mon May 20, 2024 12:19 pm I'm guessing the OP has a cable driven mechanical speedo rather than an electronic one?
Sure!
Then you need one DC motor and halfh bridge for 12V. AND you need to test how much RPM you need from the motor for full dial.
I am thinking one simple DC motor https://www.aliexpress.com/item/3285606 ... ry_from%3A

Motor driver that responds to PWM
https://www.aliexpress.com/item/1005005 ... ry_from%3A

https://www.aliexpress.com/item/1005002 ... ry_from%3A

Or you could simply replace speedo and install new sensor to the driveshaft
https://www.aliexpress.com/item/1005006 ... ry_from%3A

Re: Driving mechanical speedo from CAN

Posted: Mon May 20, 2024 4:10 pm
by Zieg
Hmm, how accurate would that dc motor be over time? At least with a stepper (and possibly a gearbox) you can control the speed directly - and know that it's consistent.

Re: Driving mechanical speedo from CAN

Posted: Mon May 20, 2024 7:50 pm
by muehlpower
Uppertown wrote: Mon May 20, 2024 11:21 am This place has a stepper motor that should do;

https://www.omc-stepperonline.com/12v-3 ... ch=42blr53
There is a smaller driver for this motor. 5A is sufficient. It can also be controlled via RS485, then everything is digital and aging and temperature do not matter.
https://www.omc-stepperonline.com/de/di ... w-bld-405s

Re: Driving mechanical speedo from CAN

Posted: Thu Jun 27, 2024 12:22 am
by nubster
muehlpower wrote: Mon May 20, 2024 10:13 am There are ready-made solutions for 400€ - 600€ from dakota digital or speedhut. An Arduino with a stepper motor should work. The speed could be a problem, as you need up to approx. 3000 rpm.
How would one go about driving the Speedhut speedometer via Openinverter?

The manual for the Orion MPH variant indicates it's expecting speed on PID 0x257 with an internal scaling of 0.1 and the units in MPH.

Is it just a matter of calculating the ratio of your motor RPM to your MPH, multiplying by 10 to account for the internal gauge scaling, and entering that as the gain in the CAN mapping?

For example:
A Tesla SDU has a 9.34:1 gear ratio and can rev to 18,000 RPM.
18,000 / 9.34 = ~1,927 Wheel speed
MPH = Wheel RPM × Tire diameter × π × 60 / 63360

So for me: 1,927 x 24" x π x 60 / 63360 = 137.59 MPH (top speed)
18,000/137.59 = 0.0076439:1 (RPM to MPH ratio)
So, would I enter 0.0764 as the gain in the "speed" spot value CAN mapping?

According to the wiki, floating point numbers are allowed as of FW v5.27, but how many decimal places are supported? How would/can you achieve this pre-v5.27? Am I way overthinking?? :)

Re: Driving mechanical speedo from CAN

Posted: Thu Jun 27, 2024 10:24 am
by muehlpower
I have an Arduino in my CAN system. This makes it easy to convert any speed information from CAN or anywhere else and output it at the correct address with the correct scaling.

Re: Driving mechanical speedo from CAN

Posted: Fri Jun 28, 2024 11:48 pm
by nubster
muehlpower wrote: Thu Jun 27, 2024 10:24 am I have an Arduino in my CAN system. This makes it easy to convert any speed information from CAN or anywhere else and output it at the correct address with the correct scaling.
Are you using the Motor RPM/SPEED CAN message from the Openinverter board to determine your road speed on the Arduino?

Re: Driving mechanical speedo from CAN

Posted: Mon Jul 01, 2024 5:27 pm
by espriev
An off the shelf GPS module puts out a 0-5VDC signal in direct proportion to actual vehicle speed.
I am using the one in the ANT P/S steering control module to also drive the electronic speedometer, using the formula speed = voltage x 50.
You would likely need a simple current amplifier to run a motor that will run the mechanical speedo, but you would retain the odometer function (I loose it it my set-up)

Re: Driving mechanical speedo from CAN

Posted: Tue Dec 03, 2024 8:42 pm
by leftcoast
I think we're getting close to the same result but in different ways.
I take the inches per mile and divide it by the tire circumference . That gives me the number of rotations per mile which I multiply by the gear ratio of 9.34 which gives me the number of motor rotations per mile. In my case:

63,360 / 80 = 792 rotations per mile
792 * 9.34 =7397.28 Which I round up to three significant digits getting 7400 rotations per MPH.
Which at 60 miles an hour seems about right.. 1 mile per minute.
nubster the number you show in your calc is the MPH to RPM ratio..
so the question is which number goes in the scaling? the RPM to MPH or the MPH to RPM?
I presume its the former..
I'm still trying to get the gauges to communicate. Anyone know if they need a termination resistor? There's nothing else in the system but the drive unit and the gauges.
UPDATE yes a termination resistor fixed it.