EcoModder.com

EcoModder.com (https://ecomodder.com/forum/)
-   Open ReVolt: open source DC motor controller (https://ecomodder.com/forum/open-revolt-open-source-dc-motor-controller.html)
-   -   CougArd Explorer (https://ecomodder.com/forum/showthread.php/cougard-explorer-13463.html)

Greg Fordyce 06-03-2010 07:09 PM

CougArd Explorer
 
2 Attachment(s)
I have assymbled one of the Cougar controllers and need a way to protect my lithium battery pack if the SOC is getting low. The controller can limit battery amps if you send a command over the serial port, for example "bat-amps-lim 200" will prevent the controller from drawing more than 200 amps. So the idea is this, when my bms sends a low battery signal I tell the controller to lower battery amps. Just keep doing this, reducing battery amps more and more until you get to 1 amp ( setting the value to zero disables the battery amp limit). This will allow you time to get the car off the road without suddenly cutting all power.

So how to send this command to the controller? I have set myself a few rules, first and most important is the controller will not be modified from the kit/design that is available. This will help prevent forking of the controller project. I will make up the rest of the rules as I come up with them! :D My controller is sealed now so I can't go in and start changing things.

I am using a Arduino Mega to comunicate over the serial port with the Cougar controller. VERY IMPORTANT, DON'T CONNECT A ARDUINO DIRECTLY TO THE SERIAL PORT ON THE CONTROLLER. The voltages on the controller serial port are +/-10 volts and will likely fry something. You need to use a serial to ttl adapter that converts the serial voltages to the 5v ttl voltage on the arduino. I am using a Sparkfun RS232 Shifter SMD
It took me a while to figure out how to connect it. You need a "null modem" or crossover cable, basically it switches pin 2 and 3 on the rs232 ports. Then to connect to the arduino you connect RX on the Shifter to TX on the Arduino and TX to RX, plus a 5v and ground wire. The reason I am using the Mega is it has 4 hardware UARTS for serial comunication. I have a Tellymate Shield connected to the main serial port, the cougar connected to the second and my BMS will be connected to the third, sending battery amp and amp hour data.

So far I can send commands to the controller, save and display the data stream on a lcd monitor. By connecting the low voltage warning from the BMS, to the Arduino, it will then send the appropiate commands to the controller. I will probably start with a simple look up table such as;

warning 1 - 200 amps
warning 2 - 150 amps
warning 3 - 100 amps
warning 4 - 50 amps
warning 5 - 20 amps
warning 6 - 1 amp
:turtle:

I will post the sketch after I have done some more work on it.

Greg

MPaulHolmes 06-03-2010 11:59 PM

That is very clever, and just plain beautiful. You are what they call an "Engineer". They grow them real smart over there in Scotland!

By the way, if I had my own controller, yours would look way more fancy and professional. Nice job!

mrbigh 11-20-2010 04:02 PM

CougArd Explorer
 
Greg, what is the outcome of your Arduino interface?

Greg Fordyce 11-21-2010 06:22 AM

Quote:

Originally Posted by mrbigh (Post 205222)
Greg, what is the outcome of your Arduino interface?

Sadly at the moment it is on hold. The first priority is getting my EV on the road, after all the CougArd Explorer isn't much use without an EV to put it in. :rolleyes: I have all the bits, but other things keep getting in the way, work, major house renovations and life in general. I am thinking about buying a can of time, but even it's on back order! :eek:

Seriously though, I am moving away from the Arduino platform for this, at least for the moment. The original reason for choosing the Arduino was because my BMS couldn't support serial comms faster than 9600 baud and the Cougar is at 19200. So the idea was for the CougArd Explorer to sit in between the Controller and my BMS and maybe eventually move the BMS master functions to the CougArd Explorer.

But things have changed on the BMS front and the project can now support 19200 baud serial comms. This is because we have moved from the original Picaxe chips to using bare Microchip pics and the Pic Basic Pro development environment. So now I have the possibility of directly connecting the bms to the controller. The first task will be to get the current limit working as I described above when the battery pack starts getting low. Then I want to monitor data from the controller starting with battery amps and amp hour data. The BMS has a built in current measurement, but I want to use the bms current data for battery charging and dc-dc loads from my pack. This will allow a smaller and more accurate sensor for this and use the controllers motor amp sensor for the motor load.

With the Arduino I was able to send commands to the controller and also read the serial data. Parsing the data string and storing the values to variables was proving a bit harder, but this looks to be quite simple with PicBasic, although I haven't actually tried it yet. :eek: Another advantage of PicBasic over the Arduino is connection is possible with a couple of resistors, no RS232 level shifter required.

My plan is to get the car on the road soon and get back to working on this project early in the new year.

Greg

Greg Fordyce 12-05-2010 11:12 AM

CougArd Explorer rides again!
 
Now that my car is nearly on the road, after more than a year of working on it,:( I am looking again at my CougArd Explorer idea. The basic idea is to give some of the functionality of the rtd explorer program in a small embedded platform. Originally I was going to use a Arduino for this, hence the name. The Arduino has been ditched, but I like the name so am going to keep it. That, and I am too lazy to think of a new name! :p

So while I am waiting for my µLCD-32PT(GFX) - 4DGL Display Modules to arrive, I have written some code for it. At this point I want to prove that I can send commands to the controller, receive the data stream and store the values into variables that can be manipulated/displayed. This code should display as text the data from the controller. It compiles o.k., but probably has lots of bugs in it. So here it is, but please note, I am a rubbish programmer. I am however open to lots of suggestions on improving the code.:D

Code:

#platform "uLCD-32PT_GFX2"

/*----  CougArd Explorer by Greg Fordyce. Version 0.01alpha 05/12/2010 -------
------    4DGL Workshop 3 Version 3.1.0.4 - Platform uLCD32PT_GFX2    -------
------------------------compiled size 791 bytes of 15360----------------------

**************************** General Information ******************************

This software carries no warranty or guarantee of any kind! Use at
your own risk, and I make no claims as to its suitability for a particular
function. Prospective users must evaluate the system before using it, and no
liability will be entertained by myself in any shape or form whatsoever.
The software has been produced at low cost for the benefit of
the EV & electronic community. The software is available free via the internet.
Users may modify or adapt the system as they see fit. If you are not fully
competent to work on potentially lethal battery systems and high voltages,
then do not experiment with or use this system. Be aware that vehicle
modifications can lead to invalidated insurance and warranty issues. You the
end user remain fully liable for any modifications made to your vehicle.

/****************************** Description ************************************

This software is to capture the real time data stream from the cougar controller
and display it in a graphical interface to the driver. This first version is a
proof of concept and just displays the info as test after capturing and storing the
data to variables. It compiles o.k. but has not yet been tested on the actual
display. It probably has lots of bugs in it at the moment. More info, see links.
http://ecomodder.com/forum/showthread.php/cougard-explorer-13463.html
http://ecomodder.com/wiki/index.php/ReVolt

/************************* Connection warning ***********************************

The cougar controller uses a serial RS232 port if built to the standard design.
The uLSD-32PT_GFX2 uses 3.3v ttl level serial comms (5 volt tolerent). You must use
a serial to ttl level shifter/converter. Direct connection of the display to the
serial port will likely damage the display.
*********************************************************************************/
///////////  Constants  ////////////////////////////////////////////////////////////


///////////  Data  /////////////////////////////////////////////////////////////////

#DATA byte rtd_pointer 3,10,17,24,31,39,47,53      // Address locations in cougar data string for values

#END


///////////  Variables  ////////////////////////////////////////////////////////////

var i, p, n;
var cougTXbuf[10];  // This will allow us to build strings of up to 20 characters to send commands to the controller
var cougRXbuf[33];  // Data string format from controller
                    //"TR=xxx CR=xxx CF=xxx PW=xxx HS=xxxx RT=xxxx FB=xx BA=xxx AH=xxx.x\r\n"
var coug_rtd[9];    // Data from controller
                    // [0] TR 'throttle'
                    // [1] CR 'current reference'
                    // [2] CF 'current feedback'
                    // [3] PW 'PWM'
                    // [4] HS 'heatsink'
                    // [5] RT 'raw throttle'
                    // [6] FB 'fault bits'
                    // [7] BA 'battery amps'
                    // [8] AH 'amp hours' note: the 1/10 value is ignored

func rtd_capture()                              // This function parses the rtd string and assigns
                                                // word values of all integer numbers found  in the string

    n:=str_Find(&p,"TR");                      // Check for valid string from controller
    if (n > 0 && n < 3)                        // "TR" should be found at front of string
        i:=0;
        while(str_GetW(&p, &coug_rtd[i++]) != 0);    // parse cougarRXbuf and store values to coug_rtd
        com_Init(cougRXbuf,33,0);              // reset RX buffer
    else
        n:=0;                                  // if we get here there is a problem with the string
    endif
endfunc

func main()
    com_SetBaud("COM0","1920");                        // Cougar comms is 19200 8-n-1
    gfx_Cls();
    gfx_Set(SCREEN_MODE,LANDSCAPE);
    txt_Set(FONT_SIZE, FONT2);
    com_Init(cougRXbuf,33,0);                          // set up a interrupt driven ring buffer for comms
    com_TXbuffer(cougTXbuf, 10);                        // set up the TX buffer
    //com_TXbufferHold(ON);                            // probably not required here
    to(cougTXbuf); print("rtd-period 500\r\n");        // Cougar sends rtd string every 500ms
    //com_TXbufferHold(OFF)                            // probably not required here
    pause(10);                                          // wait for response from controller
    while(com_Count()) putch(serin());                  // print echo response from controller to screen

    p:= str_Ptr(cougRXbuf);
    repeat
    while(!com_Full()) continue;                        // wait till com buffer fills
    rtd_capture();                                      // Check rtd data
            if (n != 0)                                // print rtd variables
                i := 0 ;
                print("Throttle is  ", coug_rtd[i++], "\n");
                print("Current Ref  ", coug_rtd[i++], "\n");
                print("Current Fdbk  ", coug_rtd[i++], "\n");
                print("PWM          ", coug_rtd[i++], "\n");
                print("Raw Heatsink  ", coug_rtd[i++], "\n");
                print("Raw Throttle  ", coug_rtd[i++], "\n");
                print("Fault bits    ", coug_rtd[i++], "\n");
                print("Battery Amps  ", coug_rtd[i++], "\n");
                print("Amp Hours    ", coug_rtd[i], "\n");
            else
                print("ERROR: ", [STR] cougRXbuf, "\n"); // print buffer as diagnostic output
                com_Init(cougRXbuf,33,0);                // reset RX buffer
            endif
    // endif

    forever
endfunc


Greg Fordyce 12-05-2010 05:49 PM

Cougard Explorer on Launchpad
 
I have added this project to the Ubuntu Launchpad site. It is a code hosting site like Sourceforge that manages revisions in software. One of the neat things is anyone can create a branch of the project, and their changes can be merged with the existing project. Be warned that if you have never used it before the learning curve is very steep, don't ask me any questions about it as I am still trying to figure it out myself. :confused:

Anyway here is the link. https://launchpad.net/cougard and you don't need to register to view or download files, only if you want to contribute through the launchpad site.

sawickm 12-06-2010 08:20 AM

Quote:

Originally Posted by Greg Fordyce (Post 208033)
I have added this project to the Ubuntu Launchpad site. It is a code hosting site like Sourceforge that manages revisions in software. you don't need to register to view or download files, only if you want to contribute through the launchpad site.

Greg,

I added your link to the Open ReVolt Wiki under "Software"; Open ReVolt - EcoModder

Mark :D

Greg Fordyce 12-29-2010 12:28 PM

Small steps and virtual controllers
 
1 Attachment(s)
I have had some time to sit down with the 4d display and have got it to read the data stream from the controller. :) Well not exactly the controller, but a virtual controller using the arduino that I was originally going to use for this project. ;) I have attached the arduino sketch, it's just a very simple loop that spits out a data stream.

So the display can read the ascii data stream, just have to get it to store the data in some variables, but this bit has me stumped at the moment. So I have posted a question on the manufactures forum. Can't extract numerical values from ascii string. - 4D SYSTEMS FORUM

Greg

Greg Fordyce 01-02-2011 06:15 PM

I've got a simple version that is capturing the data stream. Newest files uploaded here. ~greg.fordyce/cougard/trunk : files for revision 2

jackbauer 01-09-2011 07:13 AM

Just purchased the display from 4d systems so will hopefully be able to help out with this project. Have you any pics of the display and information on connecting the hardare?


All times are GMT -4. The time now is 03:44 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Content Relevant URLs by vBSEO 3.5.2
All content copyright EcoModder.com