# using arduino boards with sheilds for controllers



## moxncal (May 26, 2010)

has anyone tried using the arduino board with the added motor controller sheilds to control their electric motor? i think this would be a much more economical way of controlling the motor...eh?


----------



## Georgia Tech (Dec 5, 2008)

I am not sure what ardunio boards are.....what are they?


----------



## moxncal (May 26, 2010)

arduino boards are every tech geeks toy. they are used to control and do lots of things. its basically like having a micro and small functioning computer board but in a diy style. go check it out. http://www.arduino.cc/


----------



## Jan (Oct 5, 2009)

I haven't yet, but since I'm still in the design and restoration phase, I'm considering it, because I want a completely different pedal behavior than most controllers/inverters let me do. So, I'm considering placing an arduino in between to do the job. But -the sadly banned- Jack Rickard has the real experience with them, and they seem very vulnerable of the voltage spikes (some) controllers make.


----------



## ga2500ev (Apr 20, 2008)

The control board really isn't the challenge. For example you could get the control board for the Open ReVolt (design/build thread here):

http://ecomodder.com/forum/showthread.php/paul-sabrinas-cheap-diy-144v-motor-controller-6404.html

That actually has all the electronics necessary to drive and monitor a PWM motor controller.

The challenge is the power electronics. The MOSFETs/IGBTs, capacitors, and diodes, along with proper design so that they don't go boom.

ga2500ev


----------



## Snakub (Sep 8, 2008)

Yes I control my car with arduino and believe me programming is not easy. I had to get someone to help me with it that had been doing it for years and even he had problems with it.That is why I think that arduino is more of a toy than a programmers tool. Here is the code the pwm frequency is 7.8 kilohertz. I asked on the forum for a prewritten code and Jack Bauer wouldn't fork it over so here it is for everyone free and eventually I will work in an LEM Sensor for over current protection. Why this isn't already on the forum here is beyond me. Get together here people.


```
/* 
Timer/Counter2 PWM mode = 3
Counting sequence :  WGM21& WGM20 in TCCR2 

Compare Output mode , Fast PWM mode.
COM21  = 1; COM20 = 0 ( non-inverting mode ) 

TCNT2 inc or dec 
OCR2  compare with Timer/Counter
when TCNT2 == OCR2 
PWM output == OC2 (  PD2 ???), will go low until counter reach MAX. 
Clock source ==  CS22:0

Frequency = Fclk/( N.256) 
== 16 x 2^20 /( 8 * 256) 
==  2^24 / ( 2^3 * 3^8 ) 
== 2^13 == 8K cycles 
*/
#include  <avr/io.h>
#include <avr/interrupt.h>

int OCR2Pin =  11; 
int analogpin = 0;
int dutyCycle = 0; 

#define  bit_on(BYTE, BIT)  BYTE |= 1 << BIT;

void setup() {
   pinMode ( analogpin, INPUT);
  pinMode ( OCR2Pin, OUTPUT);
  //  set dutycycle == 50 
  OCR2 = 128 ; 

  // SET PRESCALE == 32  page 119 ( 16M / 32/ 256) == 1.9K frequency  
  TCCR2 &= 0xF0 ;  // preserve 4 msb bits 
  TCCR2 |= _BV(CS21) ;  //prescale = 8
  
   // SET MODE 3 ( waveform Generation, fast pwm ) page 117
  bit_on (  TCCR2, WGM21) ;
  bit_on ( TCCR2, WGM20) ;
  
  // SET COMPARE  OUTPUT, FAST PWM MODE ( PAGE 118) 
  // CLEAR OC2 ON COMPARE MATCH,  non-inverting mode
  bit_on( TCCR2, COM21);   
  
  //  TIMER/COUNTER INTERRUPT MASK REGISTER (TIMSK) 
  // SET OUTPUT  COMPARE MATCH
  bit_on ( TIMSK, OCIE2) ; 

  // START FAST PWM  MODE 
  bit_on( SREG, SREG_I);
}

void loop() {
; 
}

ISR(  TIMER2_COMP_vect) {
  int analog = analogRead( analogpin)/4;
   OCR2 = analog ;
}
```
Btw this code works only for mega8's and works for almost any pot and if I were you I would use a throttle position out of the junk yard for free they already have a built in spring. Also don't waste your money on one of those fruity azz control boards from paul and sabrina they are overly complicated compared to self made arduino board and an optocoupler between arduino and driver to the mosfets or whatever you are using as a power section I myself use a 4n35 optocoupler.


----------



## JimDanielson (Oct 19, 2008)

I wish I still had my code, but using this library I was able to get around 16khz(within a few khz of this) driving an IGBT. I did not use an optocoupler, although I would if I ever did it again. I only had a problem with my mosfet driver, it was not rated to drive my 600A igbt. 

http://www.arduino.cc/playground/Code/Timer1

This library makes the code very simple. The arduino is so useful! I used it the other day to record measurements across my shunt and got efficiency.


----------



## adamj12b (May 4, 2009)

Snakub said:


> Yes I control my car with arduino and believe me programming is not easy. I had to get someone to help me with it that had been doing it for years and even he had problems with it.That is why I think that arduino is more of a toy than a programmers tool. Here is the code the pwm frequency is 7.8 kilohertz. I asked on the forum for a prewritten code and Jack Bauer wouldn't fork it over so here it is for everyone free and eventually I will work in an LEM Sensor for over current protection. Why this isn't already on the forum here is beyond me. Get together here people.


Did you ask Jack on the forum or by PM / Email for the code? I am good friends with him and have never know him to hold back on helping others out with this stuff.



Snakub said:


> Btw this code works only for mega8's and works for almost any pot and if I were you I would use a throttle position out of the junk yard for free they already have a built in spring. Also don't waste your money on one of those fruity azz control boards from paul and sabrina they are overly complicated compared to self made arduino board and an optocoupler between arduino and driver to the mosfets or whatever you are using as a power section I myself use a 4n35 optocoupler.


 

Im sorry you feel that Paul's control board is too complicated for you, With all the saftey features it has and conviences. The hardware over current shutdown circuit will cut the pwm to the gate driver in nS where the micro will take mS. This was actually added because of what happend to Ian Hooper's power section went up in smoke because of a software problem. The logic gates prevent a locked up micro from causing trouble. There is also the simple cirtury that checks 12V and 5V and shuts down the gate drive if the 12V source or 5V regulator fail. Not to mention the built in contractor drive and thermal sensing circuitry. This design was professionally laid out and the firmware was programmed by a professional with many years of experience building and programming motor controls.

Also, All the parts between the accessory battery and the traction battery are isolated to 3KV.

-Adam


----------



## Snakub (Sep 8, 2008)

Its a good board yes especially given the choices out there like paying $3000 for a Soliturd 1 but his choice of c language is not truly open source especially when you consider you have to either purchase a chip from him 18 plus shipping or buy a programmer that is over 100 dollars and if you are thinking about buying the intelligence board and all components expect to pay 120 easily. Correct me if I am wrong but the kit used to be 400 now they are up to 600 hundy and when you get it you have assembly you have to figure your time is worth something if are not careful expect to make to mistakes nobodys perfect. If you are going to go diy you might as well get serious and start from the ground up and go with some big power modules like Jack and others here my KS621K30's have been holding out for 1000 miles no overcurrent protection and I am running 168 volts but I am using liquid cooling mind you. No jack never got back to me from my posts or pm's.

To Jimbo12d what did you finally end up going with to drive those IGBT's? I use a solid state relay to drive my transistors.


----------



## Qer (May 7, 2008)

Snakub said:


> like paying $3000 for a Soliturd 1


I see you're a pure bundle of happy friendliness doing your best to spread love, joy and happyness to the EV-community. Soliturd? Really?



Snakub said:


> but his choice of c language is not truly open source


Gnu gcc is open source, maintained by the Free Software Foundation. Sure, it's GPL which does limit what you can do with the actual compiler, but using it is free even for commercial use. And AVR lib-C, which most AVR-projects use as far as I know, is BSD-licensed so that's definitely open source.

You might want to look into winavr too if you run Windows. No charge, just download freely from sourceforge.



Snakub said:


> or buy a programmer that is over 100 dollars


Or you could take an old printer or modem cable and make your own programmer. It's not hard, at least if you know which end of the soldering iron to point away from you.

http://www.electroons.com/2009/07/31/programmers-for-avr-serial-parallel/



Snakub said:


> and when you get it you have assembly you have to figure your time is worth something if are not careful expect to make to mistakes nobodys perfect.


Soooo... You mean that you're not prepared to pay for the time Paul put into the project but still want him to serve you a preassembled kit, free of charge, so you don't blow anything up?


----------



## JRP3 (Mar 7, 2008)

Snakub said:


> Its a good board yes especially given the choices out there like paying $3000 for a Soliturd 1 ...... and when you get it you have assembly you have to figure your time is worth something if are not careful expect to make to mistakes nobodys perfect.


So your time is worth something but the time spend developing and producing a 1000 amp 300+ volt controller that already has the bugs worked out isn't worth anything? If you paid yourself a reasonable wage for all the time you had in your controller how much would it cost you?


----------



## Snakub (Sep 8, 2008)

In parts I spent about 320 330 it really didn't take that long to build it the hardware really wasn't a problem for me it probably would have taken just as long to put together the p & s kit maybe longer. It was just the software and finding out how to heighten the frequency with the arduino that sort of set me back because I don't know much about software. Once the Ardiuno is used more frequently for ev applications and a good solid code is built up its going to be hard to beat for just 18 dollars a board.


----------



## ewdysar (Jun 15, 2010)

Snakub said:


> In parts I spent about 320 330 it really didn't take that long to build it the hardware really wasn't a problem for me it probably would have taken just as long to put together the p & s kit maybe longer. It was just the software and finding out how to heighten the frequency with the arduino that sort of set me back because I don't know much about software. Once the Ardiuno is used more frequently for ev applications and a good solid code is built up its going to be hard to beat for just 18 dollars a board.


So once we all have free access to other people's time investment into R&D and software development, these boards will become a much more cost effective answer? I guess those "other" people had better get to coding, I've got money I'd rather spend on other things than pay someone for some expensive controller design. 

Eric
Business software developer for more than 25 years.


----------



## Qer (May 7, 2008)

ewdysar said:


> So once we all have free access to other people's time investment into R&D and software development...


----------



## Snakub (Sep 8, 2008)

The guy helping me with the code is a really good teacher too and he is more than happy to help me and help further the EV cause besides and welding together chassis and helping him mount the motors on a big line follower for him which I am more than happy to do so it is not really free labor. Qer come on man don't be that way Ra Ra Sis boom Bah.


----------



## Tesseract (Sep 27, 2008)

Snakub said:


> The guy helping me with the code is a really good teacher too and he is more than happy to help me and _help further the EV cause_ besides and welding together chassis and helping him mount the motors on a big line follower for him which I am more than happy to do so it is not really free labor. _Qer come on man don't be that way Ra Ra Sis boom Bah._


I might be going out on a limb, here, but I'm guessing you don't know why Qer might not find your comments to be very funny...   



Snakub said:


> ...Also don't waste your money on one of those fruity azz control boards from paul and sabrina...





Snakub said:


> Its a good board yes especially given the choices out there like paying $3000 for a Soliturd 1...


I'd advise you to not piss off the very people who might be capable of helping you, but it's really too late for that, isn't it?


----------



## JRP3 (Mar 7, 2008)

Just in case the subtlety is lost, Qer was the programmer for the "Soliturd1"  His demands to be compensated for hours and hours of work, along with the demands of the hardware designer for the same, drove the price up.


----------



## marcexec (Feb 11, 2009)

*Re: using arduino boards with shields for controllers*



JRP3 said:


> along with the demands of the hardware designer for the same, drove the price up.


And who might that be? Maybe another poster in this thread?

lmao 

BTW I am a lurker who read through the corresponding controller build threads.

Regarding Jack Bauer - it's currently holiday season in Ireland - maybe he's off?


----------



## jackbauer (Jan 12, 2008)

Nah I don't get holidays. I work "24" hours a day

Anyway just to clear a few things up. Snakub i did receive your pm but life just gets in the way sometimes. In any event i did not write arduino code capable of driving an ev controller. Its literally 2 lines that spit out an 8khz pwm dependent on an adc input. Its on my laptop that i use for work hence was never easy to just tap a few keys and send it to yourself. Yeh ok i'm lazy so apologies on that note. If you still want it i'll dig it out. No conspiriacy , not going to patent the thing or anything.

I spotted this thread a few days ago and decided that in light of posts being made i'd steer clear. What I do know is this. Yes its frustrating to see a great product like the soliton at what at first appears to be an inflated price that makes it out of one's reach. We're all used to getting massively complex technology for peanuts these days thanks to cheap foreign manufacturing and "consumer culture". Thats not the case here. Probably never will be.

I'm an electronics engineer but had never designed power electronics systems until i built an ev. I simply could not have done so without the help received on this and other forums and without the work done on the revolt. I have and will contiune to give back the knowledge I have gained to help other where and when i can. 

I laugh sometimes when I hear in the same sentence "....no jobs.........too expensive...."


----------



## Dave Koller (Nov 15, 2008)

jackbauer said:


> nah i don't get holidays. I work "24" hours a day
> 
> Anyway just to clear a few things up. Snakub i did receive your pm but life just gets in the way sometimes. In any event i did not write arduino code capable of driving an ev controller. Its literally 2 lines that spit out an 8khz pwm dependent on an adc input. Its on my laptop that i use for work hence was never easy to just tap a few keys and send it to yourself. Yeh ok i'm lazy so apologies on that note. If you still want it i'll dig it out. No conspiriacy , not going to patent the thing or anything.
> 
> ...


yep   ---------------------------


----------



## Jimdear2 (Oct 12, 2008)

Tesseract said:


> I'd advise you to not piss off the very people who might be capable of helping you, but it's really too late for that, isn't it?


 
My god Jeff . . . You mean you and your partner actually expect to be paid for something you did and that I (and most of us) don't the skills or ability to do ourselves.

MY what a novel concept.

There are still a few countries where that idealism is still present. Maybe snakub would like to go there. Of course no one there is willing to put out an effort like yours there because they can live off the labor of others.


----------



## JimDanielson (Oct 19, 2008)

To drive my IGBT with the arduino, I was using a UCC27321p. I did not have a gate resistor in the circuit and I think this is why it blew up. I now bought a tc4422, it can be mounted to a heatsink, I will also use a gate resistor. I have not had time to test this out yet.

One thing I heard is that igbts require negative bias to fully turn off while mosfets do not. I am not sure how to set up the negative bias, or if this is true. 

Also, do I need a capacitor from mosfet driver positive to negative?


----------



## jackbauer (Jan 12, 2008)

Here are a few guidelines for igbt driving and general applications. Firstly you need a very "strong" voltage source to supply the gate drive circuit. By strong I mean such that it does not tend to dip or sag under pulse loads. This can be achieved in a number of ways but in its simplist form is a regulated supply with heavy filter capacitance and very short leads or traces from the supply to the driver.

Many good driver chips are available cheaply that take care of a lot of the problems. I've recently been experimenting with the ACNW3190-000E with promising results. 

Most commercial drivers tend to go to +15v and -7v. This complication can sometimes be avoided by using steering diodes (either shottky or fast recovery) in series with the driver resistors. This allows for some control of the turn on and turn off waveforms.

Another basic design law is to minimise the bus link lines from the caps to the switch. And dont skimp on capacitance. Typically you'll need two types of cap. Big electrolytics to take care of the surges and smaller film caps to take out the esl from the big guys.

Consider desaturation detection to protect the devices.


----------



## JimDanielson (Oct 19, 2008)

If I am using a IXF230N20T Mosfet (200v, 230A) and a TC4422 (9 a mosfet driver)

Driver:
http://ww1.microchip.com/downloads/en/DeviceDoc/21420d.pdf

Mosfet:
http://ixdev.ixys.com/DataSheet/DS100133(IXFK-FX230N20T).pdf

Can I wire the driver output directly to the mosfet gate?


----------



## jackbauer (Jan 12, 2008)

I would advise a gate resistor. Easiest way is to pick one say 10r and observe the gate - source waveform then change as necessary.


----------



## gdirwin (Apr 7, 2009)

Thought I would pass along a bit of information I came across - I attended a presentation from a major manufacturer of power system controllers (IGBT inverters for large power system applications - hundreds of MWs). They had a number of issues with their inverters, which they ultimately tracked down to their use of the TC4422 Telcom drivers. 

They did a very extensive comparison/evaluation, and concluded that this chip did not meet the published specifications in some aspects and switched to Micrel MIC4422.

Sorry I cannot provide more details...


----------



## Hillmb (Aug 10, 2010)

Qer said:


> I see you're a pure bundle of happy friendliness doing your best to spread love, joy and happyness to the EV-community. Soliturd? Really?
> 
> 
> 
> ...



I liked the Build your own programmer link, but it was dead, so I dug around and found the new URL - 
http://www.electroons.com/electroons/site_index.html

- I love the internet, you can find anything here


----------



## Automcdonough (Sep 1, 2010)

I have a pretty stout driver laid out here power-wise but I'm totally new to playing with micro's. I've seen a ton of stuff being done witht he arduino, it's definitely popular enough to get easy software support and random upgrades.

http://hackaday.com/ seems to come up with some random new project someone did with that every day.



> The new Arduino Duemilanove (2009) is a microcontroller board based on the ATmega328. It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started.


(from here: http://www.makershed.com/ProductDetails.asp?ProductCode=MKSP4)

It seems to me that it has enough I/O to do the job, even for an AC motor.



edit:
http://www.youtube.com/watch?v=yJEBdPKUVIo

one of you guys??


----------



## stickytechnology (Sep 19, 2010)

Check out my attempt at a 3-phase (low voltage & current) arduino shield here:http://stickytechnology.com/

I haven't gotten around to posting the design files, but if there is interest, I will.


----------



## Automcdonough (Sep 1, 2010)

I'd be interested


----------



## stickytechnology (Sep 19, 2010)

I've set up a Google code project for this design over at: https://code.google.com/p/threephase/

It's still pretty rough, but it's a start. Please let me know, either here or through the Google code interface, about annoyances you run into.

As far as the hardware-- it works, but I need to do more work documenting its uses and limitations. 

I'd be willing to share hardware with someone willing to help out with the task of documentation (and better software)


----------

