Jump to content
Sign in to follow this  
Stacker

rsr232 to microcontroller (PIC) - (Moved)

Recommended Posts

Hi i need help for communication from/to PC to microchip PIC.

i need to send "ADC1xxx" (where xxx is delimiter)  to microcontroller via serial port and wait for response (with timeout)
i need to send other "commands" and waiting always a response from microcontroller.

 

can anyone help me

Yhanks so much

Share this post


Link to post
Share on other sites

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team


"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites

@Stacker
I think that you can take a look here.
Let us know :)

Best Regards.


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites

Thanks, works.

I send command from pc and micro back the response.

But i need to know how i can retry more data (sort of protocol). Ex: if i send one command Adc1 wait for response,.adc2 wait ... etc. All work.

If i try to read all ADC, 8channel, one time and send data back  to pc i read everytime different value. 

Share this post


Link to post
Share on other sites

Can you please do a practical example? :)
Thanks


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites

Finally i do with COM udf, i send command from autoit and picmicro get data back. I work on micro code to solve my problem..The com udf works fine

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Satvik
      Hi 
      I am trying to open a dll using DLLOpen, however everytime i try to do so the function fails and returns -1 result. 
      I have the dll in the same folder as the auto it script. 
      Local $hDLL = DllOpen("C:\Users\310255155\Downloads\COMMGvv2\commg.dll") DllCall($hDLL, "int", "MessageBox", "hwnd", 0, "str", "Some text", "str", "Some title", "int", 0) DllClose($hDLL) MsgBox(0,'result',$hDLL)  
    • By joseLB
      This topic is a complement of  therealhanuta´s >CommAPI - Serial and parallel communication with Windows API
      I think these routines are great, as they are simple to use, and use windows API with NO DLL´s.
      It is about tips in receiving binary data thru a serial port, including value 0 (=end of string**). I hope it can help someone..
      To know about the UDF to read/write serial port, please refer to the above link, with focus at post #3 and over
      First, what is a binary stream? As an example, a microcontroler (PIC) getting data thru ADC and sending the 2 adquired bytes straight thru serial, without any treatment.
      Now supose the message has: 1 letter(A-Z)  + 4 ADC values + 3 counters of anything (each one byte). Your message will arrive with 1 + 4 x 2 + 3 = 12 bytes (or as AU3 sees it,  a "string" with 12 "chars").
      $sResult = _CommAPI_ReceiveData($hFile) will have at $sResult a "string" with 12 "chars" ** besides the first one, all other chars have byte values. On them can exist even binary value 0. So, it´s vital that 0 be not interpreted as end of string by receiver (PC) now let´s separate the 1 + 4 + 3 = 8 fields field1= StringMid($sResult,1,1) ;this is just a characte rbetwen A-Z field2= ASC(StringMid($sResult,2,1)) ;LSB of the ADC value. First byte = LSBb, 2nd. byte = MSB field2= field2 + ASC(StringMid($sResult,3,1))*256 ;MSB of ADC => now field2 has LSB + MSB (betwen 0-65535) ;field3..5 are similar to field 2, just increase by one the start position in stringMid field6= ASC(StringMid($sResult,10,1)) ;now field6 a "number" betwen 0-255; ;field7-8 are similar to field 6, just increase by one the start position in stringMid ** - be carefull, as probably $sResult = _CommAPI_ReceiveData($hFile) will get just the chars avaiable at the moment of call, so a kind of test/loop will be necessary to get all them, something like
      $sResult="" DO      $sResult = $sResult  & _CommAPI_ReceiveData($hFile) UNTIL stringLentgth($sResult) >= 12 Jose
      ** thanks Martin into explaining about hex (0) to be interpreted as end-of-string and not xoff.
×
×
  • Create New...