Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/30/06 10:42
Read: times


 
#108686 - State Machine
Responding to: ???'s previous message

You could implement a finite state machine in your tx isr that formats the modbus message on a character by character basis. My usual method, though, is to have a ram buffer for the largest message and have the tx isr read from that. If I'm doing modbus ascii, I have a state machine in the tx isr that converts the binary modbus message (rtu format) to ascii. There's many ways to do this - it really depends on how much ram you have, how the modbus register information is stored (I have both ram and eeprom based registers) and what else you want to do.

My normal procedure is:

rx isr collects the receive packet into buffer, sets a flag when it has a packet (rtu = timeout, ascii - cr/lf).

main line code tests flag - if set, checks the crc (if rtu),length,modbus addr == our slave addr and modbus command.

each command has a subroutine that decodes the packet and does what is necessary and creates the response packet in ram then fires off the tx isr to acutally send the packet

do other stuff.

go back to start

List of 12 messages in thread
TopicAuthorDate
Sending a large array out a serial port            01/01/70 00:00      
   Solved as per above            01/01/70 00:00      
   state it more clearly            01/01/70 00:00      
      More Clearly Defined Question            01/01/70 00:00      
   State Machine            01/01/70 00:00      
      State Machine            01/01/70 00:00      
         data consistency            01/01/70 00:00      
            ISR Calculating the CRC            01/01/70 00:00      
   A possibly irelevant thought...            01/01/70 00:00      
      Protocol Intercharacter Timeout            01/01/70 00:00      
   a simplification            01/01/70 00:00      
      Buffer size            01/01/70 00:00      

Back to Subject List