Arduino Can Bus Variable Speed

I recently started programming with Arduino and CanBus shield Elecfreaks. Currently I'm making a project 'new' cluster into an older vehicle. I want to use CAN bus shield for ARDUINO UNO and my goal is to write a program to convert some input data in hex format into CAN and send them on CAN bus.

So, can I use it in inverse application? (to put data on CAN bus) and send it(variable) over CAN bus protocol via cluster (canbus).

Anyone can help my problem? :confused:

Question 1) How to make it variable for byte5 & byte6 (speed)

Question 2) It is possible vss square wave (PWM) convert to HEX can id?
If can't. How to make it variable PWM at byte5 & byte6.

Thanks

paul_reference.ino (3.81 KB)

Is this for a hobby or a commercial product?

mikb55:
Is this for a hobby or a commercial product?

for hobby

what happends when you run the code such as

 //Conversion Low and High Bytes
  speedL = lo8(roundedKph);
  speedH = hi8(roundedKph);
......
  //Speed
  CanSend(0x052, 0x00, 0x00, 0x00, 0x00, speedL, speedH, 0x00, 0x00);

does it display anything?
also add some print statements to check that roundedKph, speedL, speedH, etc have sensible values
do you have a Canbus monitor so you can check information flow on the bus - I tend to use a CAN-USB dongle for a PC

wanek123:
Q : does it display anything?
A : NO.

Nothing happen on the cluster @horace.

I suggest adding some print statements - roundedKph, speedL, speedH, etc may be 0

How CAN BUS - USB dongle function ?? It is same as canbus shield ? for send & received data.

I use a CANUSB to monitor the Canbus using a PC
similar devices are available on ebay for £20-30 - they tend to have a GUI which allows one to monitor data, set up parameters (speed, RTR, staandard/extended ID, masks, filters, etc) and send data to the bus
If you have a spare Canbus shield there is a Arduino_Canbus_Monitor on github

Thanks for reply @horace

So far code working with 4-Digit 7-Segment (Display Adafruit 0.56") without error.

Video : speed without can id - YouTube

is the canbus working OK then?