UART COMM
Moderator: Benj
UART COMM
Hello,
I have a board that communicates through UART but has 4 pins - RXD , TXD , CTS , RTS .
Can I communicate with it with flowcode?
If I use the RS232 component will I be able to control CTS & RTS?
As far as I know RS232 component uses only TX, RX so what about CTS, RTS?
What is the TX,RX voltage output?
Also If I want to connect it via SPI, which PIC 18F877A pins correspond to MOSI, MISO, SCK, SS ?
Thank you,
Best Regards,
Andreas Achilleos
I have a board that communicates through UART but has 4 pins - RXD , TXD , CTS , RTS .
Can I communicate with it with flowcode?
If I use the RS232 component will I be able to control CTS & RTS?
As far as I know RS232 component uses only TX, RX so what about CTS, RTS?
What is the TX,RX voltage output?
Also If I want to connect it via SPI, which PIC 18F877A pins correspond to MOSI, MISO, SCK, SS ?
Thank you,
Best Regards,
Andreas Achilleos
Re: UART COMM
Hello
So you will be able to communicate. The 232 properties FLOWCODE set the hardware flow control (disabled by default). Then you can choose the pins responsible for the RTS and CTS. Remember that uP operate on 5V or 3V3, and the standard RS232C typically at 12V. Therefore, the communication between PC and uP need a converter such as .: MAX232
Witam
Tak można będzie się komunikować. W właściwościach RS232 flowcode ustawiasz sprzętową kontrolę transmisji (domyślnie wyłączona). Wtedy można wybrać piny odpowiedzialne za RTS i CTS. Pamiętaj o tym iż uP operują na napięciu 5V lub 3V3, a standard RS232C typowo na napięciu 12V. Dlatego też do komunikacji pomiędzy PC a uP potrzebny jest konwerter np.: MAX232
So you will be able to communicate. The 232 properties FLOWCODE set the hardware flow control (disabled by default). Then you can choose the pins responsible for the RTS and CTS. Remember that uP operate on 5V or 3V3, and the standard RS232C typically at 12V. Therefore, the communication between PC and uP need a converter such as .: MAX232
Witam
Tak można będzie się komunikować. W właściwościach RS232 flowcode ustawiasz sprzętową kontrolę transmisji (domyślnie wyłączona). Wtedy można wybrać piny odpowiedzialne za RTS i CTS. Pamiętaj o tym iż uP operują na napięciu 5V lub 3V3, a standard RS232C typowo na napięciu 12V. Dlatego też do komunikacji pomiędzy PC a uP potrzebny jest konwerter np.: MAX232
Re: UART COMM
Hello siwo278,
Thank you for replying, the board I have can be connected directly to an MCU/PIC so it is not necessary to convert it to RS232, how ever as you say; I can choose the RTS & CTS through the component's properties, yes?
Do you know the SPI pins MOSI, MISO, SCK, SS how they correspond to the PIC 18F877A?
Thank you
Thank you for replying, the board I have can be connected directly to an MCU/PIC so it is not necessary to convert it to RS232, how ever as you say; I can choose the RTS & CTS through the component's properties, yes?
Do you know the SPI pins MOSI, MISO, SCK, SS how they correspond to the PIC 18F877A?
Thank you
Re: UART COMM
Hello
Yes RTS and CTS select the properties of the component. (for pictures). when it comes to SPI interface I am far not figured him. Far enough for me to RS232 and RS485.
Witam
Tak RTS i CTS wybieramy przez właściwości komponentu. (na obrazkach). jeśli chodzi o interfejs SPI to narazie do niego nie doszłam. Narazie wystarcza mi RS232 i RS485.
Yes RTS and CTS select the properties of the component. (for pictures). when it comes to SPI interface I am far not figured him. Far enough for me to RS232 and RS485.
Witam
Tak RTS i CTS wybieramy przez właściwości komponentu. (na obrazkach). jeśli chodzi o interfejs SPI to narazie do niego nie doszłam. Narazie wystarcza mi RS232 i RS485.
- Attachments
-
- rstest2.jpg (330.53 KiB) Viewed 21975 times
-
- rstest1.jpg (311.48 KiB) Viewed 21975 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: UART COMM
Hello,
MISO = SDI = RC4
SCK = RC3
SS = Slave RA5 / Master Any Free I/O
More info: http://www.matrixtsl.com/blog/simplifie ... c-and-spi/
MOSI = SDO = RC5Do you know the SPI pins MOSI, MISO, SCK, SS how they correspond to the PIC 18F877A?
MISO = SDI = RC4
SCK = RC3
SS = Slave RA5 / Master Any Free I/O
More info: http://www.matrixtsl.com/blog/simplifie ... c-and-spi/
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: UART COMM
Thank you a lot Ben!
I have a question though and I quote from the http://www.matrixtsl.com/blog/simplifie ... c-and-spi/ link you gave me
Thank you,
Best Regards,
Andreas Achilleos
I have a question though and I quote from the http://www.matrixtsl.com/blog/simplifie ... c-and-spi/ link you gave me
Can I apply this when I try to connect my MCU to a 3.3V board while communicating via TX/RX (UART)? OR should I use resistor/voltage divider (2kΩ/1KΩ)One of the great upsides of the I²C bus is that it can do voltage level shifting for you. For example say we have a Master running at 5V but a slave running at 3V3. The I²C pullup resistors are connected between the signals and 3V3 allowing the bus to float at 3V3. The Master can still recognise the 3V3 input voltage as a logic one and no nasty 5V is allowed to reach and potentially damage the slave.
Thank you,
Best Regards,
Andreas Achilleos
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: UART COMM
Hello Andreas,
The UART is a driven bus meaning you don't rely on external pull up resistors to provide the logic 1 level.
Therefore yes you should probably use a resistor based voltage divider to reduce the TX voltage from 5V to 3V, your resistor values look perfect. The RX pin can be left as is as the output will be from the 3V3 side and should work ok with the 5V device.
Some 3V3 devices also have 5V tolerant pins so you could check this if you know what the device is.
The UART is a driven bus meaning you don't rely on external pull up resistors to provide the logic 1 level.
Therefore yes you should probably use a resistor based voltage divider to reduce the TX voltage from 5V to 3V, your resistor values look perfect. The RX pin can be left as is as the output will be from the 3V3 side and should work ok with the 5V device.
Some 3V3 devices also have 5V tolerant pins so you could check this if you know what the device is.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: UART COMM
Ben one last thing...
I am currently testing the V6 flowcode, I was used to v4. I need some help with the RS232 macro properties.
1. If I need to receive a word such as: "hello" from my peer board talking to MCU, what would I choose; ( receiveChar or receiveString)?
2. What do I enter in the -Expression- field?
3. If I enter a variable in the expression field , then in order to print on screen the incoming data, should I use that variable or I should still select a return value and assign it to the aforementioned variable which was entered in the expression filed?
4. It seems that I cannot enter to a decision icon the following expression : Inchar>0 Variable Inchar is a string. I need to enter the decision when the return value or RS232 macro which is Inchar ; when is above 0. The error I receive:"incompatible operands for operation"
Thank you,
Best Regards
I am currently testing the V6 flowcode, I was used to v4. I need some help with the RS232 macro properties.
1. If I need to receive a word such as: "hello" from my peer board talking to MCU, what would I choose; ( receiveChar or receiveString)?
2. What do I enter in the -Expression- field?
3. If I enter a variable in the expression field , then in order to print on screen the incoming data, should I use that variable or I should still select a return value and assign it to the aforementioned variable which was entered in the expression filed?
4. It seems that I cannot enter to a decision icon the following expression : Inchar>0 Variable Inchar is a string. I need to enter the decision when the return value or RS232 macro which is Inchar ; when is above 0. The error I receive:"incompatible operands for operation"
Thank you,
Best Regards
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: UART COMM
Hello,
The receive string allows a number of bytes to be received and stored into a string variable. The receive byte only receives a single character.
You could receive a string and then use the string compare function in a decision to check for the word "hello".
Inchar = ReceiveString
Then you can add the following code into a decision icon.
Compare$(Inchar, "hello", 0) == 0
However there are problems with this approach. For example if the string you receive contains "xhello" or "hellox" then the comparison will return false.
I instead like to go down the route of using the RXINT interrupt to collect the databytes as they come in. Then use a circular buffer component to store the data. The circular buffer has search functions so you can do something like search for "hello" which will be a lot more reliable than the string comparison.
An example of this is available from here.
http://www.matrixtsl.com/wiki/images/6/ ... ridge.fcfx
More help on the circular buffer component is available from here.
http://www.matrixtsl.com/wiki/index.php ... Storage%29
The receive string allows a number of bytes to be received and stored into a string variable. The receive byte only receives a single character.
You could receive a string and then use the string compare function in a decision to check for the word "hello".
Inchar = ReceiveString
Then you can add the following code into a decision icon.
Compare$(Inchar, "hello", 0) == 0
However there are problems with this approach. For example if the string you receive contains "xhello" or "hellox" then the comparison will return false.
I instead like to go down the route of using the RXINT interrupt to collect the databytes as they come in. Then use a circular buffer component to store the data. The circular buffer has search functions so you can do something like search for "hello" which will be a lot more reliable than the string comparison.
An example of this is available from here.
http://www.matrixtsl.com/wiki/images/6/ ... ridge.fcfx
More help on the circular buffer component is available from here.
http://www.matrixtsl.com/wiki/index.php ... Storage%29
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: UART COMM
Hello Ben,
1 . I have tried the "circular buffer" example on my MCU, and AS IT IS; it works just fine, I send data from android app, I get them on MCU and then I get the reply from MCU.
However I have noticed that if I take the routine and put it in a loop, in order to have constant communication between the devices , then the communication starts to have problems.
What I mean, when I receive reply data from MCU, the data that were received and are in the buffer; sometimes instead of getting ( 12345 ) I get (123.5), and peculiarly, almost always is the number 4 that is represented by a dot (.) !
2 . When I send data to the MCU and I send 6 bytes instead of 5 ( five macros are in the routine for storing data) then the sixth byte is being stored somewhere and then when I send again 5 bytes , I get as reply the redundant one and the first 4 of the last bytes: e.g. send > 123456, theMCU replies 12345, when I send again > 12345 the MCU replies 61234.
I get this even if I include a macro that says "flush buffer"
3 . I have noticed that if I let the routine run and go up to the end -without loop- and then hard reset the EB-006 then the communication is fine. So I have tried to enter the main routine to a loop and then have an interrupt to call the main routine in order to have a "fresh" run of the main routine but still I get errors in receiving data in the correct order.
> Is there a way instead of having the routine in a loop to auto reset the MCU?
Can you tell me how many bytes can be stored while receiving RS232 data?
Thank you,
Best Regards,
Andreas Achilleos
1 . I have tried the "circular buffer" example on my MCU, and AS IT IS; it works just fine, I send data from android app, I get them on MCU and then I get the reply from MCU.
However I have noticed that if I take the routine and put it in a loop, in order to have constant communication between the devices , then the communication starts to have problems.
What I mean, when I receive reply data from MCU, the data that were received and are in the buffer; sometimes instead of getting ( 12345 ) I get (123.5), and peculiarly, almost always is the number 4 that is represented by a dot (.) !
2 . When I send data to the MCU and I send 6 bytes instead of 5 ( five macros are in the routine for storing data) then the sixth byte is being stored somewhere and then when I send again 5 bytes , I get as reply the redundant one and the first 4 of the last bytes: e.g. send > 123456, theMCU replies 12345, when I send again > 12345 the MCU replies 61234.
I get this even if I include a macro that says "flush buffer"
3 . I have noticed that if I let the routine run and go up to the end -without loop- and then hard reset the EB-006 then the communication is fine. So I have tried to enter the main routine to a loop and then have an interrupt to call the main routine in order to have a "fresh" run of the main routine but still I get errors in receiving data in the correct order.
> Is there a way instead of having the routine in a loop to auto reset the MCU?
Can you tell me how many bytes can be stored while receiving RS232 data?
Thank you,
Best Regards,
Andreas Achilleos