Hello I would like to read several analog voltage signals from a vehicles sensors Brake pressure, oil temp etc. and output them to a separate data logger in a can format.
Reading the voltages is well documented but sending them out to the MCP2515 I have not seen unless using the DTH sensors. These will be only voltage values that I will add the configuration on the receiving end on an AIM solo2 DL.
Thanks for the reply.
I have casually programmed since 1990s in C as well as Python. I am new to doing anything with this environment as I have usually been in the PLC and Honeywell automation while working. I have some working knowledge of electronics, understand pull up and pull down circuits as well as a fundamental knowledge of components resistors capacitors, RTDs Thermocouples, coils etc.
Currently I do data analysis and wire mutable race car systems for data acquisition using the vendor equipment. The systems have analog inputs and they are limited to usually 10 or 12 inputs but the can bus can receive up to 144 inputs. It is my hopes that I can use this platform to develop a low cost data acquisition system to add to the cars. I typically use an Axiomatic AX030120 unit that takes 10 universal signal input analog or digital type inputs (0- 5V, 0-10V, 0-20 mA, 4-20 mA, Digital, PWM, Frequency/RPM or Counter). This is around $400 US. From there I can assign the bit addressing and usually create a DBC file for the input stream.
This is a small sample
BO_ 883 RR_Temps_4: 8 RR (* the 883 is decimal it is actually 0370 hex)**
SG_ RR_Ch16 : 55|16@0- (0.1,-200) [-3476.8|3076.7] "° C" Vector__XXX
SG_ RR_Ch15 : 39|16@0- (0.1,-200) [-3476.8|3076.7] "° C" Vector__XXX
SG_ RR_Ch14 : 23|16@0- (0.1,-200) [-3476.8|3076.7] "° C" Vector__XXX
SG_ RR_Ch13 : 7|16@0- (0.1,-200) [-3476.8|3076.7] "° C" Vector__XXX
Using the input voltage I can scale the output For example:
A standard pressure sensor with a 0-150 psi range and a linear curve from 500mV to 4500mV can be expressed in psi by altering the gain and offset. First, calculate the slope of the line and you can use the slope of line formula for this Gain=(y2-y1)/(x2-x1)
where y is the unit value of the sensor and x is the voltage value of the sensor. In our example the formula will look like Gain=(150-0)/4500-500) so gain will be set at 0.0375. Then consider that this line does not pass through 0,0 so we have an offset. The offset is 500 but it is altered by the gain so we take our gain and multiply it by the offset 0.0375x500=18.75.
PSI= 0.0375(2500mV)-18.75= 75PSI
What I am looking to do is take the raw value of the sensor in voltage add the ID to the value and send it out on the bus. It would look like this (ID) 0CF00400 FF FF FF 68 13 FF FF FF (Data). From there I will be fine. I am just new to Arduino and hope to come up with a lower cost solution.
If I am off base again sorry this is new to me and I will try to get better.
8 bit signed or unsigned either big or little Endian up to 64 bytes I keep it 8 as most of the data I see on the bus is that. Yes floats are acceptable but usually this is standard temperatures and pressures. As mentioned I would like to take analog values in voltage from the A0- A5 inputs translate to a hex number and typically in 2 bytes and put 4 in to an 8 byte data fame with a address. From there I am good to go..
By default analog values have a 10 bit resolution which would need 2 bytes. Do you really need to convert that to an ASCII hex representation? Most likely you would just send the number as is.
Populating an 8 byte array is just a matter of shifting data along until it gets to the right place, or you can use a union to treat a byte array as a particular data type.
Yes I need the hex representation to work in the Bosch Controller Area Network environment. Since that is an industry standard there are many tools for that. So I really don't know how Arduino with a can shield would do it. I have looked for this but have not found this being new to this environment I really don't know even to look.
The CAN shield only knows about byte arrays.
It's up to you to convert your numbers into ASCII hex then copy the individual chars to the right locations in the byte array.