Tuesday, January 19, 2010

Assembly and Programming

 (Last revised 1-30-2013)

This section contains hints on hardware assembly the hardware, loading the Firmware, and Hardware bring-up hints.



Hardware Assemble hints

 (Last revised 1-31-2013)
  • Install SMD Diodes and INA220's 1st, need lots of room to 'work around them'.
  • Take care that Silk Screens for 2N3904 transistors are backwards, need to swap the FLAT side vs. what is on the silk screen.
  • R29 Seems too close to the fuse holder, I mounted mine on the underside and encased it in Hot Glue for protection.
  • Note the traces that need to be 'reinforced' around the Voltage Regulator.  See
  • P2/P10 is ordered as one long component.  Clip off the extra pins in the middle before installing it (them).  I did it this way as it assures good alignment between the two connectors, for future 'expansion' cables.
  • Install L2 last (LM7805/U9 on later boards).  This will allow a simple Ohm check between +5 and Gnd looking for any shorts.
  • I had a lot of problems with a Vcc to Ground short under U3 (PCB 0.1.3).  Be careful not to get too much solder on that part, as I could not remove excess solder bridging pin 1 and 2.  I had to remove the part and start over.
  • And order extra INA-220's just in case of the above!
  • Hold off installing C6 and C8 until you have brought up the board and verified the two INA220's are working.  Leaves room to rework them. . . 
  • I found a Flux-Pen VERY helpful!
  • For soldering the SMT devices (INA-220s and BAV99 diodes).  There are LOTs of hints on the web, and some good videos on You-tube.  Some additional notes:   I first 'tinned' the pads using good tin/lead based solder.  Then using Solder wick I removed all excess.  I also found the method of creaking up along the PCB pads worked best for me when soldering in the INA-220s, as opposed to placing heat / solder on the ICs leads directly.
  • If you do not have an existing Arduino board around that you can use to load the bootloader (See below), or you do not want to bother with that step - make sure the CPU you order already has the Arduino boot-loader flashed in. 
  • Pins which are connected to either the GND or Vbat planes need a LOT of heat to solder correctly, esp the large bypass diodes like D17..D20.  I used a 40W iron.
  • It is a good idea to go back and reflow all the TO-220 parts after yo mount the heat sink, to relieve any stress there might be on the package via the pins.  Or better yet, only solder the middle leg - install the heat-sink, release pressure on that middle leg and solder the rest of them.



PCB Errata

An errata summary can be found under the resource link 'Schematic'.  In attition, this link has some more details and photos


http://smartdcgenerator.blogspot.com/2010/01/pcm-errata.html








LOADING THE ARDUINO BOOT-LOADER

Once the hardware is assembled, the Arduino boot loader needs to be programmed into the Amtel CPU.   If you wish to skip this step, it is possible to purchase Amtel-328 CPUs with the Arduino boot loader already  installed, but if you have a spare Arduino board around it is simple to use it to program the Amtel CPU.

While researching this I came across what appears to be a fault in the version 1.0 Arduino environment - namely the simple steps built into the environment will not work with all Amtel boards - and specificity will not work with the Arduino Uno.  I however found this solution:  https://github.com/WestfW/OptiLoader
(You can also download the version I used from the Arduino Libs tab above)


To use the optiLoader, you need to download the two files: optiLoader.pde and optiLoader.h   Place these two files into a new subdirectory called OptiLoader where your personal sketches are stored (default is:  MyDocuments/Arduino).  Then connect up the following wires from the Arduino to the controller board's ICSP connector:

Host Arduino pin     ISPC Pin
     D13                         3 (SCK)
     D12                         1 (MISO)
     D11                         4 (MOSI) 
     D10                         5 (~RESET)
     GND      6 (GND)

-OR-  Optionally, you can use a small breadboard and directly burn a batch of raw Atmel CPUs, connect as:  (This is actually how I do it, esp as the OptiLoader program does a trick to turn the power on and off, it is very easy and quick to do a batch of these at one time)

Host Arduino pin              Atmel CPU Pin #
     D13                            19  (SCK)
     D12                            18  (MISO)
     D11                            17  (MOSI)
     D10                              1  (~RESET)
      D9                               7, 20 (+5v)
     GND           8, 22 (GND)



To provide power to the controller board, run a wire from the Arduino gnd to one of the '-' jacks on any o the one-wire temperature sensor connects (ala EMT or BT).  Also run a wire from the Arduino boards +5v to the "+" jack.   Open up your Arduino development environment and load the optiLoader sketch into the Arduino.  Then open the Serial Terminal in the development environment and you should see something like this:
Successfully programmed the Boot Loader into the controller CPU
(Click on image for larger view)


Congratulations, the controller board is all ready to load sketches.




LOADING SKETCHES 

Once the boot loader is in place, 'sketches' can be downloaded via a USB <--> Serial  adapter  connected to the 'Service' port.  Here there are two options:
  1. Use an  inexpensive USB to Serial adapter 
  2. Use the one on an Arduino board.

Using an external USB to Serial Adapter

The controller is designed to use an external USB to Serial converter board plugged into the Service jack.  If you are using v0.3.x or above, the Service Port matches the 6-pin adapter noted in the Parts List and referenced in the Ordering & Costs tab above.  If you have a prior PCB, it matches a different USB adapter that needs a simple modification before using to  bringing out the DTR single that is used to control reset.  Follow this post for details on how to modify a board:



Using Arduino board 

An alternative is to use an Arduino board, remove the CPU and use the existing Arduino USB to Serial adapter jumpering it to the Controller board.  To do so, remove the CPU on the Arduino board (here is why selecting a simple Uno with a socketed DIP CPU is nice) and make the following connections:

Arduino pin     SERVICE PORT Pin
     D0(RX)                        5
     D1(TX)                         4
     RESET                         1

Again connect up the +5 and GND power leads as above and you will be able to download sketches, but now they will go to the Controller Boards CPU.





Hardware Debugging Hints


 (Last revised 1-29-2013)



After the hardware is assembled and you are able to load sketches into it, you might try some of these ideas to slowly bring up the board and test major sub-sections:



  • Open the Arduino programming environment and load the Arduino BLINK sketch.  Change the PORT from  pin 13 to pin 9 and upload it to the controller.  This will cause the PWM LED on the controller board to blink.


This tests basic CPU operation as well as access via the Service Port.



  • Next attach a One-Wire temerature senser to anyof hte Temperature ports on the controller. Open the TESTER sketch in the DallasTemperature library.  Change the ONE_WIRE_BUS from 2 to 10 and upload this to the controller.  Open the Serial Monitor  and you should see a temperature probe working.
At this point you have tested the One-Wire subsystem.


While doing this, take note of the address associated for that probe (ala “288249600400008E”).  You will need to copy it into the SECR_Control.h file.  For example, assuming I am using this probe for my Battery  Temperature probe, make the following edit:

#define OW_BAT_TEMP {0x28, 0x82, 0x49, 0x60, 0x04, 0x00, 0x00, 0x8E}           // Battery Temp




Next, using  4 resisters, mock up the following:




The + and – positions on the Temperature Sender ports are a very convenient  place to get access to +5v and Gnd respectively.

Load and run the "SECR" sketch,  double checking the #define’s for the following switches:

      #define DEBUG
    //#define CHK_DISABLED_OP_SENDER

    //#define CHK_DISABLED_WF_SENDER


We want to include the DEBUG code, but not the Oil Pressure or Water Flow sender checks (otherwise the program will fault immediately reporting bad senders.)


After a short initialize time you should see the “Ready” screen come up on the LCD.    At this point you have tested the CPU, the I2C bus and the I2C buffer sections.  It should show the voltage of your testing supply (e.g. mine displayed 15.1v) and the EGT should = ~550.   This test both portions of the INA-220 U4.

To test the other INA-220 (U3) move the  "VBat Since –"  wire from Ground to +5.  The Volts display should now show 5v less.  Amps should =  ~160.  Finally, reverse the Current Shunt + and Current Shunt – wires.  The display should now show a -160a.   To further test, return the Shunt wires, but this time connect the shunts in parallel with the EGT resister divider .  The Amps should now display ~45A.   If all is well both the INA-220’s are working!

Leaving the Current Shunt connected in parallel with the EGT resister divider  and the VBat – Sensing wire connected to +5v (so that a low battery voltage and a small charging current is indicated to trick the controller into driving the Field PWM hardwe).  Open the Serial Monitor window, and after the initialization and the Ready Screen appears, type in a large G to simulate the ‘Generator’ button being pressed.  You should see the controller ‘ramping’ the PWM up on the bottom line of the LCD, and also as shown in the detailed debug information being displayed on the Serial Monitor window.


Congratulations!   It looks like things are working!   If you wish, simple LED /  resisters can be attached to the driver ports (remember they are at 12-15v, not 5v so use a larger then normal resister),  You can then 'watch' the throttle control and clutch control lines work.  Or, you can mock-up the full simulator.  Or, just bolt it up to the real thing!  But do make sure to edit the config data 1st to match your situation.






Configuring and Loading Firmware


Following the instructions under the Assembly tab, make sure you can communicate with your controller and remote LCD board using the USB <--> TTL adapter and the Arduino IDE tool.  Download all the libraries from the 'Arduino Libraries' tab above and place them in your local working libraries directory (My Documents/Arduino/libraries on a Windows machine).  Then download the Source code for the LCD remote and Controller from the 'Source Code' tab above, placing these in the appropriate working Sketch directory (My Documents/Arduino/ on a Windows machine).  Opening the Arduino IDE, select the correct serial port COMM address where the USB <--> TTL adapter has been placed and verify the Board Type is 'Arduin UNO'.

You then need to edit the configuration file for SERC_Control, see here for guidance:
      http://smartdcgenerator.blogspot.com/2014/07/configuring-for-your-system-editing.html

Once this is done you can simple copy new revisions of the source code into these existing directories, leaving the config.h file with your customizations.

Then to compile and download the firmware, select File/Sketches and the appropriate sketch.  More details on using the Arduino IDE can be found at:  http://arduino.cc/





No comments:

Post a Comment