More work on ECU/Modbus project

Done loads of work on the ECU/Modbus project.

Modbus interface to Adaptronic Simulator works, the Modbus lib I found was sadly only a slave lib, but the modbus master code wasn't hard to write from scratch :)

Serial LCD acquired and happily displaying messages on it.

Begun a UI lib to control with a joystick for display on the serial LCD.

Writing files to SD is as easy as I hoped :D

Got a servo on the way to try for the needle. :)


4 comments

24 Jul 2011

Hi,

Did you write the master code seperately or did you embed it into the library by using some of the functions in the library?

Thanks,

24 Jul 2011

You can use this as a base. Not very pretty as I just wanted to see if I could get something working with the Adatronic simulator

http://mbed.org/users/tecnosys/programs/Adaptronictmp/lutcaf

 

24 Jul 2011

Thank you very much for sharing. I studied the code but I was unable to find anything related to timing, is there any utilities to ensure the timing constraints (i.e. 3,5t between two frames)? Shouldn't be very difficult though, one flag and one timeout should do the job. Anyways, again thank you very much for sharing, it will be a good start for me too.

Sincerely,

25 Jul 2011 . Edited: 25 Jul 2011

The timing code is in the receive msg (modbus.c), which I quickly commented out to get working. It should'nt be too hard to re-implement the RTU pause between frames in the send and the receive using the mbed Timer.

 

     if (msg_length_computed == MSG_LENGTH_UNDEFINED) {
                /* Wait for a message */
                //tv.tv_sec = 60;
                //tv.tv_usec = 0;

                /* The message length is undefined (query receiving) so
                 * we need to analyse the message step by step.
                 * At the first step, we want to reach the function
                 * code because all packets have that information. */
                msg_length_computed = mb_param->header_length + 2;
                state = FUNCTION;
        } else {
               // tv.tv_sec = 0;
               // tv.tv_usec = TIME_OUT_BEGIN_OF_TRAME;
                state = COMPLETE;

and here in modbus.h

 

/* Time out between trames in microsecond */

#define TIME_OUT_BEGIN_OF_TRAME 500000

#define TIME_OUT_END_OF_TRAME   500000

 

You need to log in to post a comment