tag:blogger.com,1999:blog-9120755343492164185.post3281531847681164667..comments2024-01-02T09:50:32.183-06:00Comments on Matthew McMillan: Arduino - Sending data over a CAN busMatthew McMillanhttp://www.blogger.com/profile/02359945130001450035noreply@blogger.comBlogger125125tag:blogger.com,1999:blog-9120755343492164185.post-2895727678341286112018-06-15T16:03:37.230-05:002018-06-15T16:03:37.230-05:00Thanks for letting me know. I fixed the links.Thanks for letting me know. I fixed the links.Matthew McMillanhttps://www.blogger.com/profile/02359945130001450035noreply@blogger.comtag:blogger.com,1999:blog-9120755343492164185.post-13378693804693350622018-05-01T21:41:34.355-05:002018-05-01T21:41:34.355-05:00Hi, you have used void MCP2515_ISR() in the receiv...Hi, you have used void MCP2515_ISR() in the receiver side code. Is it a function or interrupt. If it is a function, you have not called anywhere else in the program. Can you please explain about it.<br />Thanks.Anonymoushttps://www.blogger.com/profile/13235258965811139289noreply@blogger.comtag:blogger.com,1999:blog-9120755343492164185.post-84077843416124712352018-05-01T03:45:40.001-05:002018-05-01T03:45:40.001-05:00Hello,
The libraries link is not available.Hello,<br /><br />The libraries link is not available.Anonymoushttps://www.blogger.com/profile/15155237983826496322noreply@blogger.comtag:blogger.com,1999:blog-9120755343492164185.post-74891797243841449622018-04-12T05:07:36.629-05:002018-04-12T05:07:36.629-05:00Yes. I'm now communicating to the CAN bus.
Fir...Yes. I'm now communicating to the CAN bus.<br />First, the Tx and Rx LEDS are still not flashing even the communication is working.<br />Second, I found that I was not connected to the CAN bus by connecting to OBDII connector, rather I was connected to an intermediate firewall, so I tapped into the CAN bus after I checked the car's wiring diagram.Ahmed Amerhttps://www.blogger.com/profile/04731440745488349002noreply@blogger.comtag:blogger.com,1999:blog-9120755343492164185.post-71025630638328315702018-04-02T14:59:14.580-05:002018-04-02T14:59:14.580-05:00Hello Ahmed, i have the same problem like yours. D...Hello Ahmed, i have the same problem like yours. Did you find any solution for that?Rehahttps://www.blogger.com/profile/12603550450762336278noreply@blogger.comtag:blogger.com,1999:blog-9120755343492164185.post-86273194401745364082018-03-11T05:38:43.006-05:002018-03-11T05:38:43.006-05:00Hi Matt,
I have an ARDUINO UNO with the Elecfreaks...Hi Matt,<br />I have an ARDUINO UNO with the Elecfreaks CAN-BUS shield V1.2<br />I wired the CAN-H and CAN-L to pins 6 and 14 in my car's OBDII connector and connected also pin 5 to ARDUINO's GND<br />I cut the P1 trace and measured 60ohms between CAN-H and CAN-l while connected to the car<br /><br />Unfortunately the Tx and Rx LEDs are not flashing<br />I changed the MCP pin to 10 instead of 9 and that only got me that the shield init is OK, but nothing is received<br />I tried all the supported baud rates, but still no luck<br />I have only one ARDUINO UNO and one CAN-BUS shield<br /><br />Is there anything else I can do? I'm stuck!!!Ahmed Amerhttps://www.blogger.com/profile/04731440745488349002noreply@blogger.comtag:blogger.com,1999:blog-9120755343492164185.post-36133464627261997332018-02-27T07:48:45.622-06:002018-02-27T07:48:45.622-06:00Hi Matt,
Thank you for good work. My question is h...Hi Matt,<br />Thank you for good work. My question is how we can send the sensor data on hexadecimal ?<br />with regards.Anonymoushttps://www.blogger.com/profile/12596959027577296035noreply@blogger.comtag:blogger.com,1999:blog-9120755343492164185.post-9541223923691604612018-02-26T21:57:17.048-06:002018-02-26T21:57:17.048-06:00Hi Matt
I am trying to figure out how to include ...Hi Matt<br /><br />I am trying to figure out how to include the Destination Address in the CanBus message using the Arduino Libraries?<br /><br />I am trying to interface to an industrial CanBus implementation and am trying to send the following message;<br />Prior PGN SA DA DLC Data<br /> 6 59904 254 255 3 0x4B 0x9C 0x00<br /><br />The Hex data would be <br />0x18EAFFFE FF 3 40 9C 00<br /><br />I just can'f figure out to include the destination address 255 (0xFF) using the CAN.sendMsgBuf() function.<br /><br />Thanks!<br /><br />Darel <br /> Unknownhttps://www.blogger.com/profile/06706755565261454275noreply@blogger.comtag:blogger.com,1999:blog-9120755343492164185.post-47420489870835368142018-02-22T09:14:28.135-06:002018-02-22T09:14:28.135-06:00Hi Matt
I keep getting "init fail" when...Hi Matt<br /><br />I keep getting "init fail" when i use the code. I have tried the codes above and also those from the seeed studio library. <br /><br />I am using an Arduino uno and seeed studio can bus shield v1.2.<br /><br />Any sugestions of what might be wrong?Anonymoushttps://www.blogger.com/profile/17649302729584955196noreply@blogger.comtag:blogger.com,1999:blog-9120755343492164185.post-65491916585438210472018-02-19T11:08:11.784-06:002018-02-19T11:08:11.784-06:00Hi Matt,
Thanks for your post.
I am working on s...Hi Matt,<br /><br />Thanks for your post.<br /><br />I am working on something. I want to send the CAN messages wirelessly using LoRa to another CAN BUS connected to the receiver LoRa. I am using a multiprotocol shield to connect the CAN Bus and LoRa for each Module.<br /><br />Do you have an ideal how can I get the message from the CAN bus to the LoRa for transmittion using the SPI.<br /><br />Thanks<br />Akpo<br />Anonymoushttps://www.blogger.com/profile/11246977660258875841noreply@blogger.comtag:blogger.com,1999:blog-9120755343492164185.post-40729534809835881382017-11-13T15:58:39.141-06:002017-11-13T15:58:39.141-06:00Hi Mohib
Yes i did, I adjusted the code with som...Hi Mohib <br /><br />Yes i did, I adjusted the code with some commands. After the init my codes sends a 0x01 to all nodes. The joysticks switches to the operational mode. I also activated the heartbeat mode on the joystick with a special command. Now I can read the hex values of the joystick. <br /><br />I have written a test program to test my industrial joystick. H.Ceyhhttps://www.blogger.com/profile/16956297200495520203noreply@blogger.comtag:blogger.com,1999:blog-9120755343492164185.post-18520568935978852342017-11-06T02:36:24.907-06:002017-11-06T02:36:24.907-06:00Thanks a heap Matt. You are the best. Thanks a heap Matt. You are the best. Anonymoushttps://www.blogger.com/profile/13696167574048584521noreply@blogger.comtag:blogger.com,1999:blog-9120755343492164185.post-53131057600005905162017-11-03T21:22:53.391-05:002017-11-03T21:22:53.391-05:00You can build this with just one CAN shield. Just ...You can build this with just one CAN shield. Just like you mentioned, you could use four different CAN id's to represent each of the potentiometers. You could also use just one CAN id and assign bytes in the payload for storing the potentiometer data. For example pot1 uses byte 0, pot2 uses byte1, etc.<br /><br />CAN id's aren't tied to hardware. One device (shield) can write data to the bus with as many CAN id's as you would like. The only thing you want to avoid is having two different devices write data to the bus using the same CAN id.Matthew McMillanhttps://www.blogger.com/profile/02359945130001450035noreply@blogger.comtag:blogger.com,1999:blog-9120755343492164185.post-1976670898216981192017-11-01T08:26:27.255-05:002017-11-01T08:26:27.255-05:00Hi Matt. Great work you doing here.
Lets say I ha...Hi Matt. Great work you doing here.<br /><br />Lets say I had 4 Potentiometers and they need individual communication. can I use a single can shield on a single Arduino and assign them different addresses, or will i need 4 shields on 1 Arduino (if that's possible even), or will i need 4 of the above setup?Anonymoushttps://www.blogger.com/profile/13696167574048584521noreply@blogger.comtag:blogger.com,1999:blog-9120755343492164185.post-51865709466561553472017-11-01T08:01:02.919-05:002017-11-01T08:01:02.919-05:00Hi PhotoUnique. Did you manage to sort out your jo...Hi PhotoUnique. Did you manage to sort out your joystick related issue?Anonymoushttps://www.blogger.com/profile/13696167574048584521noreply@blogger.comtag:blogger.com,1999:blog-9120755343492164185.post-3284003418008115842017-11-01T07:59:58.923-05:002017-11-01T07:59:58.923-05:00Hi PhotoUnique. Did you manage to sort out the joy...Hi PhotoUnique. Did you manage to sort out the joystick issue?Anonymoushttps://www.blogger.com/profile/13696167574048584521noreply@blogger.comtag:blogger.com,1999:blog-9120755343492164185.post-5703482142265056752017-08-09T03:08:03.303-05:002017-08-09T03:08:03.303-05:00Hii Matt thanks for your reply, I really don’t kno...Hii Matt thanks for your reply, I really don’t know at this point. As soon as I send over 2 arduinos everything works fine. Right now I’am stuck with the joystick. <br /><br />Can it be related to the fact that the joystick isn’t in operational mode. What I read before was that, as soon as I plug my joystick in it goes in the pre operational mode. I need to send a message to put the joystick in a operational mode. <br /><br />NMT command code: 0x01 <br />Meaning: go operational<br /><br />I do not know if it has anything to do with it, its my first can related project. <br /><br />I am now stuck in implementing the sending option (for nmt commands) in my receive code. Although I do not know if this will help. For now I am searching for a solution.H.Ceyhhttps://www.blogger.com/profile/16956297200495520203noreply@blogger.comtag:blogger.com,1999:blog-9120755343492164185.post-25934690988085716292017-08-09T01:59:25.513-05:002017-08-09T01:59:25.513-05:00Thanks Matt, NP.
I have done a long stint on the c...Thanks Matt, NP.<br />I have done a long stint on the code for the arduino ECU sim and having 'started again' i have made something that at least compiles (its nothing like even marginally functional yet)..<br />it'll be much easier for you to look at the newer stuff, lots less of the other stuff that either works, has yet to be considered, or will work only later.<br /><br />newer code here: http://eightyeight.co.uk/#can_engine_sensors<br /><br />sprintf and scanf seem most likely will be a big part of the solution to parsing the CAN byte orientated messages. The string formatters compile for Uno but whether they will do as required i have no idea. They didn't compile for Due, but that's not at all important for me (after a day's hacking around with code). The stdio and iostream libaries are not equivalent across AVR and SAM boards.<br /><br />I love your 3D printed lights, really good. I am looking for some lighting to go in the garden; how might the printed filament hold up in full sun (Really, really full sun, i live 27º north latitude, Canary Islands, similar to Orlando, Fl probably. <br />Anonymoushttps://www.blogger.com/profile/14921889029886161297noreply@blogger.comtag:blogger.com,1999:blog-9120755343492164185.post-53975634480795487772017-08-07T14:26:30.167-05:002017-08-07T14:26:30.167-05:00Hard to say what the issue might be. Seems like th...Hard to say what the issue might be. Seems like the CAN controller is going into an error state. I would try it without the joystick and see if it works. That will tell you if the addition of the joystick causes an issue. Then you can start tracking down why the joystick causes problems.Matthew McMillanhttps://www.blogger.com/profile/02359945130001450035noreply@blogger.comtag:blogger.com,1999:blog-9120755343492164185.post-85828430143551426452017-08-07T14:22:30.304-05:002017-08-07T14:22:30.304-05:00Unfortunately I can't share the code from my A...Unfortunately I can't share the code from my Audi A4 simulator. It's something I built for work. I'll try and take a look at your code and see if I can figure anything out.Matthew McMillanhttps://www.blogger.com/profile/02359945130001450035noreply@blogger.comtag:blogger.com,1999:blog-9120755343492164185.post-54346213400952339172017-08-07T05:16:18.201-05:002017-08-07T05:16:18.201-05:00Hi Matt
Very glad you seem to be still with this. ...Hi Matt<br />Very glad you seem to be still with this. Many thanks so far.<br />And to further it, i read your code up to the point where you divided the analogread(potpin) by 4 to fit it in the CAN-bus one-byte messaging and i must have died a bit (or a byte). I read your response to the question here and to count the number of 255's more than there are after the first byte, put that in the second byte is good... but my real world needs a bit more. (tempted.. too tempted.. a byte more).<br /><br />I have got a long way towards building a whole ECU simulator so as to send to a ELM327 and bluetooth, numerous engine sensors that aren't usually available at the dashboard. So with Android Torque i will display Exhaust Gas Temperature, Cylinder Head Temperature and (actual) Engine Coolant Temperature on my Land Rover Discovery TD5.<br />I read on Medium about your project to put an Audi A4 on the workbench. (Is that code available, even for perusal?) I'm putting the "simulator" with real sensors in the car and CAN-busing the data to Android (cos the Torque frontend is done and nice). The car uses K-line throughout variously seven control units and none of the PIDs are published (2001MY), they're kind of unknown and actually incomplete for me; Exhaust Gas and Cylinder Head temperatures are on my own thermocouples and are foreign to Land Rover which doesn't measure those specifically. Engine Coolant Temperature, although on the analogue meter on the dash board is notorious for being a near binary and is either half-way or FSD (full scale deflection), a function of the engine ECU. I will use the NTC but not the TD5 ECU. (Splitting the NTC, Tee'ing off it, is another thread; Atmel will have no (real) effect on the NTC voltage, given the ECU must put its 10k series R with it across 5V).<br /><br />My problem for which i want help, is parsing the sensor data from analogread int and byte variables to the byte* etc required for the CAN-bus library to successfully build and send a CAN-bus message out of the Seeed Shield. <br /><br />Its a language problem more than anything for me i think. This compile error (maybe in various guises) doesn't go away regardless of what i do with and without low/highByte() >>8 &00FF etc etc... in the case of int.<br /><br /><br />quote"<br />Error compiling project sources<br />TD5_Engine_Sensors.ino: 442:38: error: invalid conversion from 'int' to 'byte* {aka unsigned char*}' [-fpermissive]<br />Debug build failed for project 'TD5_Engine_Sensors'<br /> CAN.sendMsgBuf(0x7E8, 0, PID_EGT, EGT)<br /> <br />TD5_Engine_Sensors.ino:37: In file included from<br /> <br />mcp_can.h: 126:10: error: initializing argument 4 of 'byte MCP_CAN::sendMsgBuf(long unsigned int, byte, byte, byte*)' [-fpermissive]<br /> byte sendMsgBuf(unsigned long id, byte ext, byte len, byte *buf); \\ send buf<br />"end quote.<br /><br />the full code is here https://eightyeight.000webhostapp.com/#td5-engine-sensors . My website there is barely up and running.. it was and will be again "up" properly at eightyeight.co.uk, more threads for later.<br /><br />if you could have a look and see how bad it is let me know. - i just had a quick glance through again and notice some comments aren't aligned with as is, for example the round(egt) comment says its an integer, but it has since changed, declared as byte; the comment precedes the coding - all part of the effort to get the CAN.message builder to compile. In the final comments, i also say we need only mode 2 comss, Mode 1 comms only of course, for live dynamic data; just a typo.<br /><br />Any thoughts greatly appreciated, i understand (completely) if i hear nothing back!<br /><br />BTW FWIW I use Atmel Studio 7 environ with Arduino IDE sideways- i question now why and even why i prefer it, but i do, unknown if or how it affects (anything).<br /><br />Many thanks<br />GregAnonymoushttps://www.blogger.com/profile/14921889029886161297noreply@blogger.comtag:blogger.com,1999:blog-9120755343492164185.post-9034256364146068722017-07-20T08:12:41.784-05:002017-07-20T08:12:41.784-05:00Hii Matt, can you help me with my problem. I'm...Hii Matt, can you help me with my problem. I'm using the code and when I sent messages from one arduino to the second arduino everything works great. Now I connected my arduino to an industrial joystick but the messages are empty and it stops after two messages. My serial monitor says this <br /><br /><br />-----------------------------<br />Get data from ID: 703<br />0 <br />-----------------------------<br />Get data from ID: 83<br />0 0 0 0 0 0 0 0 <br /><br />thats all.<br /><br />i hope you can point me on the right direction H.Ceyhhttps://www.blogger.com/profile/16956297200495520203noreply@blogger.comtag:blogger.com,1999:blog-9120755343492164185.post-28212102372147507132017-07-17T10:52:18.572-05:002017-07-17T10:52:18.572-05:00In this example the data is stored in an array nam...In this example the data is stored in an array named 'buf'. It's a zero based array so the number starts at zero. So byte 3 would be buf[2] and byte 4 is buf[3].<br /><br />Here is some abbreviated code that should point you in the right direction:<br /><br />CAN.readMsgBuf(&len, buf);<br />canId = CAN.getCanId();<br /><br />if (canId == 608 ) {<br /> Serial.print("Byte 3: "); Serial.print(buf[2]);<br /> Serial.print("Byte 4: "); Serial.print(buf[3]);<br />}<br />Matthew McMillanhttps://www.blogger.com/profile/02359945130001450035noreply@blogger.comtag:blogger.com,1999:blog-9120755343492164185.post-29195337468625385612017-07-12T08:43:19.280-05:002017-07-12T08:43:19.280-05:00hi matt, can you ask it to read specific bytes whe...hi matt, can you ask it to read specific bytes when reading can messages? for example i want to read ID608 byte 3 and 4.Anonymoushttps://www.blogger.com/profile/06433176770535534276noreply@blogger.comtag:blogger.com,1999:blog-9120755343492164185.post-17869383440207776132017-06-02T10:54:55.072-05:002017-06-02T10:54:55.072-05:00OK, thank you very much for your help. OK, thank you very much for your help. FJShttps://www.blogger.com/profile/14072720829001253030noreply@blogger.com