DEF Simulator using CanBed board

NOTE: before mounting in the enclosure box, the CanBed needs to be programmed! Please see instructions in the Programming section at the end of this post.

Note: The CanBed needs to have a 4 pin connector soldered on to the board

• Drill & bits
• Wire cutters / Strippers
• Small screw driver
• Ohm meter (multi-meter)
• Silicone sealant (optional)
Soldering iron & solder

Parts list:
1) The CanBed board can be obtained from several online sources. This board has the ATmega32U4 processor.  The suggested source is  p/n: 1597-102991321-ND

2) You will need a USB cable with a micro USB connector, as the board does not come with one. They are available at online retailers or in many stores. Here is one from Amazon.

3) Weather tight enclosure. The entire assembly of the CanBed is very small. The enclosures used on the UNO or DUE variants will work just fine, although they are larger than needed. Feel free to get a smaller one if desired. Here is one from Amazon that will work.

4) The cable and waterproof gland nut (shown in Quick Start section of main page) used on the DUE assembly can also be used with the CanBed.

As an alternative to the “Gland nut” you can use a rubber grommet, which can be purchased from most hardware stores, such as ACE Hardware. Just get one that will fit your cable diameter. You could also just fill the hole in the box where the cable goes through with silicone sealant.

It is recommended that you program the CanBed board before doing the assembly. Please refer to the Programming section at the end of this post.

Take the 1 Meter DT Extension cable that you purchased and cut the off the flat end with the exposed orange silicone as shown in the picture below, approximately 4 inches from the connector. The short end with the Orange silicone connector will not be used electrically, but if desired can be used as a “dust cap” for the DEF head sensor connector when the DSS is not in use.

After cutting the cable, trim back the outer jacket about 4 inches and expose the 4 inner conductors.  Be careful to not cut the inner conductors.

As noted at the beginning, the CanBed needs to have a connector soldered to the board. The connector comes with the board.  You can get a very inexpensive soldering iron kit from Amazon (see tools list )

You can optionally directly solder the cable wires to the board if you wish. If you choose to solder the wires directly, you will need to feed the wires through the enclosure first.

The wiring connections on the 4 pin DT04 connector are: +12v, ground, CAN-H and CAN-L.

The wires associated with these pins (above picture) are connected to the CanBed via the screw terminals. You will need to use an ohm meter (multi meter etc) to determine which wire is connected to which pin, as the wire color codes are not standardized.

Drill a hole through the enclosure to accommodate the cable and gland nut (or grommet, whichever you are using).  Feed cable into enclosure.

Strip about 3/16 inch of insulation off each wire end and connect to the screw terminals. Make sure the slot is fully open as shown in the picture below. If the wires are too large, you can trim off a few of the strands.  Make sure there are no loose strands sticking out of the connector.

Insert the stripped wires into the slots shown in the picture below:

Tighten the screws to securely fasten the wires in the slots.

The finished board assembly can be secured in the box using Velcro.

A completed assembly:

NOTE: before mounting in the enclosure box, the CanBed needs to be programmed! Please see instructions in the Programming section if this has not been completed.

Programming the CanBed
It is assumed that someone attempting to construct one will have a modest knowledge of a Windows based computer. The initial work was completed on a Windows 10 based machine, but it is expected that a Windows 7 or XP based machine will also work (USB drivers could be an issue). The computer will need to have at least 1 available USB 2/3 port.
The Arduino software install file can be downloaded by clicking here. The full github page can be viewed here.

When your browser opens to the page, click on the “download” button to download the file.

The download file (DEF Emulator Install Files v0.2 (x32).exe) is a self-extracting file that will include the compiled Arduino software appropriate for your hardware configuration and files for actually programming the Arduino. It is not necessary to install any additional software from Arduino or anywhere else.  The browser will typically download the file into the “Downloads” section as shown in Windows File Manager.

After the file is downloaded, just double-click the file and it will automatically create the required directory structure on your C drive and copy all necessary files into their appropriate locations. It will prompt you to verify the destination directory, accept the suggested default, which is C:\AVRProg. You may see warnings from your anti-virus software on your Windows computer and you may have to deal with those to allow the installation to run. The downloaded installation package will create the following directory structure in the root of your C:\ drive:

1) Using a micro USB cable, connect the CanBed board to your computer’s USB port. You should see a LED light up next to the micro USB port on the CanBed board. This indicates power to the board.
2) Open Windows10 Device Manager (right click on windows “start” icon in lower left of screen and select Device Manager). Look under “Ports (COM & LPT)” and you should see the board listed. Note that it may be only listed as “USB Serial Device”. Here it’s shown as COM4. If there is more than one device shown, unplug the CanBed board and see which device is removed from the list. Be sure to plug the board back into the USB port.

3) Leave the Device Manager window open. Press and release the reset button on the CanBed board.

4) Watch for the Device Manger window to refresh. Under the Ports section you probably will see the COM# value change. Note this new value. Make sure the COM# does NOT overlap with another COM device.

5) Open a Windows10 CMD window by right clicking on Windows “start” icon at lower left of screen and then left click on Command Prompt.
6) Type: cd\avrprog and then hit Enter key
7) You should see the command prompt as C:\AVRProg
8) Type: program canbed x where x is the COM port number (1, 2, 3 etc) from step 4. DO NOT hit Enter key yet!!
9) Press and release the reset button on the CanBed board
10) Wait about 2 seconds and then press the Enter key in the CMD window
11) You should see something similar to this:

And when finished:

12) Programing is now finished.

After programming, it is expected to see a LED behind the reset button flashing about once per second.  You can now disconnect the board from your computer.

29 Comments to DEF Simulator using CanBed board

  1. mike says:

    I keep getting a message while trying to program board that butterfly_recv() programmer not responding

  2. Steve LaMothe says:

    So built this solution and it worked perfectly. Was so economical I purchased and flashed 2 boards so I had a backup board just in case.
    I HAVE NOT had any issue with my sensor as of now but wanted to have this as insurance just in case it happens.
    A HUGE THANK YOU! To all that contributed to this project.
    I did notice that the link for the canbed has been lined out, I was wondering what that’s about.

  3. John W says:

    Hi. I am trying to program the CanBed solution and getting an error as follows.
    Connecting to programmer: .avrdude.exe: butterfly_recv(): programmer is not responding

    Not finding much help for my particular problem so far. Looking for some hints.

    • Archer2 says:

      Please follow the instructions carefully especially Steps number 3 & 4 AND 8 thru 10. The board uses a different USB COM port number during programming than the one that Windows initially assigns. You must use the “Reset” button to force the board to switch to the alternate port number that you determine in steps 3 & 4. This is 90% of the problems that users are reporting, the other 10% are trying to use a USB “charging” cable which does not have all of the internal wiring connected end-to-end.

  4. Archer2 says:

    To anyone who is getting an error when trying to program the CanBed that says something like “Connecting to programmer: .avrdude.exe: butterfly_recv():…” go up to the “Programming” section and pay close attention especially to Steps number 3 & 4 AND 8 thru 10. The board uses a different USB COM port number during programming than the one that Windows initially assigns. You must use the “Reset” button to force the board to switch to the alternate port number that you determine in steps 3 & 4. This is 90% of the problems that users are reporting, the other 10% are trying to use a USB “charging” cable which does not have all of the internal wiring connected end-to-end.

  5. ka0t1c07 says:

    followed the steps, kept getting avrdude.exe butterfly_recv(): programmer is not responding. I did get pass all the hardware reading prompts. Tried multiple USB cables but still no luck. Please Help

  6. dp7 says:

    The datasheet for the CanBed board does not list the board dimensions. Has anyone found a document with the board dimensions?

  7. John Painter says:

    Just finished programming my board. Great directions! Just one thing to note, in case some others, with limited Windows knowledge, have the same situation. My Windows 10 computer has a Windows Powershell instead of a Command Prompt. It works the same, for this application, with one exception. Instead of typing program canbed x, you need to type ./program canbed x

    The ./ simply tells Windows to use the current directory to find ‘program’. I guess it is a safety feature of the Windows Powershell.

    Thanks to all who spent their time on this great tool. I will feel much less stress on our next RV trip.

  8. Josh says:

    Thank you for putting this out there. I just completed the build but haven’t had a chance to test it out yet. No issues with the programming.
    I had a couple questions about it- what will the sensor values be defaulted to? Is there any way to change the “temp” or “level” in the programming using arduino?

    • Archer2 says:

      The answer to the first question is that on each startup the DEF level will be forced to 75% and will drop by a small percentage each hour that it’s on. The DEF temp starts at about 75F but then switches to whatever the ECM is reporting as ambient temp. The switch occurs as soon as there is valid data from the ECM. THE DEF quality is defaulted to 32.5% and does not change.
      The answer to the second question is since we will ONLY distribute the compiled binary run-time there are no user-defined variables.

      • Josh says:

        Gotcha. The temp might be problematic for folks when its cold as you would get a DEF frozen fault. The coolant will be allowed to warm the tank but the ambient temp will stay cold never allowing the engine to come out of the derate…But you can’t have it all.
        Can you recommend any good material or resources for learning more about how to build/program CAN emulators like this? I have seen a few “boxed” programs out there.

        • Vic Chanko says:

          You are correct about the temp sensor. This device is meant to be a do it yourself way for an RV owner to be able to get to a safe place to get a permanent repair done. Not many RVs are used when temperatures get down to 12F where the DEF freezes. If you really needed to add an external temp sensor to your project one of the developer/programmers might agree to write and compile you a custom version to support something like a DS18B20, but I doubt they would do it for free.

  9. Shane Bills says:

    Is the Digikey part number not valid, if so do you have a suggested alternative?

    • Archer2 says:

      Yes, the link is still valid. There is some kind of WordPress situation that causes it to have a strike-thru. I just ordered 2 of the Seeed CanBed units using the link and got them in 2 days via FedEx Economy.

  10. Don says:

    I am in the process of ordering the parts, but noticed that programing required a Windows computer. Can an the device be programed using a an Apple computer?

    Thanks for your work on this issue.

  11. Bill Springer says:

    We have parts coming next week to include Canbed board. I don’t see anywhere in the instructions that we need to disable termination resistors by removing jumper wires like the other boards. Can you confirm please?

    • Archer2 says:

      The CanBed board comes already configured WITHOUT any termination resistor. But just in case somebody might need for it to be terminated, it comes with a tiny slide switch that can be soldered onto the board to allow for the terminator to be switched in or out of the circuit. This switch is NOT necessary for 99.99% of users.

  12. Britt says:

    I just assembled it.. Great job on putting this out there. I have not tested yet. I did run into two thing that don’t quite match the instructions..

    1. I’m getting two quick blue flashes near the rest button after programming. Even when hooking up 12V and ground on a bench test. The instructions state one flash per second.

    2. I had to download the IDE to get the drivers installed. I am on a windows 8.1 machine.

    • Archer2 says:

      Thanks for the input. Glad you figured out the driver thing. We weren’t able to test every version of Windows and rarely does this happen but sometimes it does.
      As to the blue flashing, if it were music it would be “2 eighth notes, quarter note rest, 2 eight notes, quarter note rest” @ 120 bpm. (Counted 1& 2 3& 4)

    • Archer2 says:

      Another question Britt, did you just download the Arduino IDE with the standard, default libraries or did you also need to go to Library Manager and search for a particular library and add it? If so which library did you add?

  13. Bill Springer says:

    OK, I need help. I put Windows 10 on my Mac and downloaded the software file. When I double-click it to store on C: drive, it shows the correct place like in the instructions, then I click next and nothing happens. I went ahead and connected the board and went thru everything to the point of typing commands in the Windows Powershell and it couldn’t find the file. I’m not real proficient in Windows so anything you can provide is appreciated.

  14. Bill Springer says:

    Vic: You are the man; thanks so much for helping us set up the board. It was nice chatting with you too!

  15. Kelly Fitzpatrick says:

    I have built both the Arudino UNO version and the canbed version. I connected both to a Raspberry Pi with a CAN HAT in order to test. When I do a candump, I see slightly different messages from the two versions (first byte in second message). Both alterate between two different messages.


    $ candump can0
    can0 18FE56A3 [8] BB 3D 94 09 FF FF FF FF
    can0 18FD9BA3 [8] 3D 82 FF FF FF F3 FF FF

    Arduino Uno:

    $ candump can0
    can0 18FE56A3 [8] BB 3D 94 09 FF FF FF FF
    can0 18FD9BA3 [8] FF 82 FF FF FF F3 FF FF

    Is this expected behavior?


    • RadarEng says:

      It depends on when you programmed your UNO. When the CanBed was released, there was a minor update to all versions to include temperature in byte 1 of PGN64923. If you download the most current code and reprogram your UNO, I would expect both to have the same output.

Leave a Reply

Your email address will not be published. Required fields are marked *

© 2021: DEF Sensor Simulator | Easy Theme by: D5 Creation | Powered by: WordPress
WordPress Cookie Plugin by Real Cookie Banner