Help for connecting usr module

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
M.ali
Posts: 10
Joined: Fri Oct 05, 2018 10:30 am
Has thanked: 3 times

Help for connecting usr module

Post by M.ali »

Hi.i have a usr tcp232 and need help for connecting it to the micro.
This are the file.
Flowcode1.zip
Program
(2.91 KiB) Downloaded 244 times
USR-TCP232-T2-User-Manual-V1.0.pdf
(2.18 MiB) Downloaded 245 times

M.ali
Posts: 10
Joined: Fri Oct 05, 2018 10:30 am
Has thanked: 3 times

Re: Help for connecting usr module

Post by M.ali »

Hi to all.
the component I'm used for module is correct?
Program is working but can't recive data from pc.
Thanks for your help.

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Help for connecting usr module

Post by medelec35 »

Hi,
Yes UART (3.3 - 5V RS232) is the correct component.
If it was me, I would use RX interrupt rather than a tight loop as I believe tight loops don't work.
What voltage are you running MCU at?
Martin

M.ali
Posts: 10
Joined: Fri Oct 05, 2018 10:30 am
Has thanked: 3 times

Re: Help for connecting usr module

Post by M.ali »

Hi.
Both the micro and the module are connected to 5 volts.

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Help for connecting usr module

Post by medelec35 »

In that case are you using a lvl shifter for RX of module as signal pins are not 5V compliant?
I use a level shifter for 3V3 Bluetooth even though the supply pin is 5V tolerant like your module.
It has 5K6 from RX of module to ground & 3K3 from RX of module, in series TX of microcontroller.
I think the level shifting within the datasheet of USR module is a bit over kill, but of course that can be used if you feel happier to do so.
If you connect the TX of MCU directly to RX of USR then damage to both, especially USR module are likely to occur.
It should be fine for direct connection from TX of USR module to RX of microcontroller as current will be limited due to high input resistance of microcontroller.
Martin

M.ali
Posts: 10
Joined: Fri Oct 05, 2018 10:30 am
Has thanked: 3 times

Re: Help for connecting usr module

Post by M.ali »

Thanks. I'm just learning programming and some questions?
How to use RX interrupt?
What format should I send from pc?

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Help for connecting usr module

Post by medelec35 »

You're welcome.
M.ali wrote:How to use RX interrupt?
Drag an interrupt icon at the start, double-click on it then select

Code: Select all

UART0 RX
Click

Code: Select all

Create New Macro
and give it a suitable name.
Move the UART receive component into the newly created macro for the UART0 RX.
That's it.
As soon as a char is received, then D (which only needs to be byte or string) will contain the value that triggered the interrupt.
M.ali wrote:What format should I send from pc?
As I don't know the product, you will need to look at the datasheet and see what you need to send.
Then if you are stuck we can help you to send the data in the correct format.
There could even be forum members or staff that do now the format that could help?
Martin

M.ali
Posts: 10
Joined: Fri Oct 05, 2018 10:30 am
Has thanked: 3 times

Re: Help for connecting usr module

Post by M.ali »

Hi. I did what you said but it's not receiving data.
IMG_20181129_075000.jpg
IMG_20181129_075000.jpg (169.5 KiB) Viewed 5302 times

mnf
Valued Contributor
Valued Contributor
Posts: 1208
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 440 times

Re: Help for connecting usr module

Post by mnf »

Try something like this -

This receiving from a Bluetooth module on UART on an Arduino (any with a 328p) - note that you'll need to add

Code: Select all

#include <avr/sleep.h>
set_sleep_mode(SLEEP_MODE_IDLE); 
in a C block at the start of your code - or replace the C block that sleeps the processor with something appropriate for the MCU you are using..
snip1.PNG
(25.89 KiB) Downloaded 2016 times
And the interrupt:
snip2.PNG
(9.98 KiB) Downloaded 2016 times
The full code: (This just echoes the characters received on the UART back to the UART....)
Circular Bluetooth.fcfx
(10.97 KiB) Downloaded 196 times
(Replace the Bluetooth calls with either UART macros or macros for the device you are using)

Martin

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Help for connecting usr module

Post by medelec35 »

The interrupt and initialise components should not be in a loop as shown in your images.
They should only be accessed once at the very start.
Can you change your flowchart accordingly, then upload it again.
Martin

M.ali
Posts: 10
Joined: Fri Oct 05, 2018 10:30 am
Has thanked: 3 times

Re: Help for connecting usr module

Post by M.ali »

I did what you said but still do not get the code
I'm going to test the program with just RS232 and if it's working then usr
Documents.zip
(5.71 KiB) Downloaded 269 times
Thanks again for your help

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Help for connecting usr module

Post by medelec35 »

Have you made a 1 sec flasher test to confirm the hardware clock is running at the correct speed?

One issue I see is if you was say sending a "1" then the value of D will be 48 + 1 = 49
So if you want D to be assigned with 1 then you need to use D = D - 48.
The other thing is D will never be greater than 255 as the RX is only receiving bytes so T will never = D
You need to know what your expecting then design the flowchart around that.
For example, currently witch your flowchart you it can only receive a single value from 1 to 255.
So if a number string is sent then you can only receive the numbers 0 to 9
If you want the receive a string value higher than 9 then your current flowchart will not work.
My advice would be to test hardware with single numbers to start with.
Do you have a UART to USB converter?
If so its very easy to send 0 to 9.
If you state what you want to receive and what you want the value to do then I can see if I can assist you further
Martin

Post Reply