To control a device that communicates with rs-485 with pic mcu ttl level

Started by okmn, May 26, 2021, 11:24 PM

Previous topic - Next topic

okmn

hi guys,
I want to connect to a device that communicates with ttl level rs-485 with PIC16F19176 and control / manage it.

I decoded the incoming and outgoing data of the device (with salea logic pro 16)

but in what order (how) should I control max485's "RE, DE" pins? I couldn't figure it out over uart rx tx pins.

By the way, I made the ttl uart to ttl rs485 converter circuit and I can control the device with it ,PIC16F19176 with uart rx tx
First of all, I have to send the data that it expects (the device) and it sends an answer right after it and this has to be like this all the time.
If I do not send data (if there is no request, the device does nothing and does not send data.

When I send data, the motor inside the device starts to rotate (according to the speed information byte / bit value in the data I send)
and the device sends back information about the speed at which the motor is rotating in response.

Can you share a few snippets of code that you wrote with pic and rs485?

Adsız2.jpg

Giuseppe

Both RE and DE must go to 1 when the device (877) transmits. Then when 877 receives RE and DE they must be at 0.
You could use the Wait function if you know which character you get first

joesaliba

You can tie to ground RE to always listen.

I did that a while ago, had three devices on same line, RE tied to ground to always listen, and then only toggle DE to transmit if master asks to.

Joe

okmn

i will not have multi device on same line which are  communicate with uart

my project will have like this schematic.

Adsız2.jpg

the device which one communcated with rs485 never can send any data if F19176 does not  want from it.(if F19176 does not sent "request data" to it)
for this reason F19176 does not need waiting in rx mode for listen non stop.
but while rs485 device reciving data from F19176 it can start sending data to F19176 (there are 3 buttons on the rs485 device ,speed up-down and motor start/stop buttons.

so, F19176 must in listen mode for the lcd (any time any data can come from it)uart interrupt i must use for it.

when the data came from lcd ,F19176 will make some comment and will start send non-stop data to the rs-485 device to drive the motor.((If the data does not come from F19176 to this device continuously, the motor does not rotate)

which kind of algorithm i must make if a new data come from lcd to F19176 and while F19176 continues sending data to the rs485 device (so that the motor does not stall) can you have any suggestions?fot code algorithims.*

okmn

i decided use  PIC16F19176  for this project ..
Let's see, if I can accomplish this project with a new series of pic mcu !!

Giuseppe

Basically only MCU transmits and the device receives via Rs485 right?
But the device does not transmit to MCU

See_Mos

OK, RS485 with only one device (single drop)  is basically RS232 with data direction so the first thing we need to look at is the data sheet for the motor.

What is the make and model of the motor or can you provide a link to the data sheet?

okmn

Quote from: Giuseppe on May 31, 2021, 06:44 AMBasically only MCU transmits and the device receives via Rs485 right?
But the device does not transmit to MCU

device has a simple  3 phase small motor via its own control board comunicating 485 
pıc mcu sending data to the device motor's control board on 485 line then control board driving the motor

if pıc mcu does not sent any data device can never  sent any data to the pıc mcu..and never run...

the data i think totaly 12 byte data ( I still continue to decode the codes whenever I get the chance!! )..





okmn

Quote from: See_Mos on May 31, 2021, 09:04 AMOK, RS485 with only one device (single drop)  is basically RS232 with data direction so the first thing we need to look at is the data sheet for the motor.

What is the make and model of the motor or can you provide a link to the data sheet?

device is not sigle drop it is multi drop but device in sleeping mode waiting until pıc mcu start sent command/request data to/from it ...

the motor does not have any label but the board has a motor driver ic and one stm mcu(it can an atmelmcu also i could not remember now )...


Giuseppe

You need to know the commands and syntax to be sent to the engine to write the code to be run by the mcu.
Don't have a manual for that card?

okmn

no manual , i  just can see the 2 mcus name for their datasheets
i will decode data than i will write here

See_Mos

Is this for a stepper motor control board, a stepper motor with internal control or a permanent magnet motor?

I just noticed that your drawings are not quite right.  RE and DE got to an I/O pin that is set low to receive data and high to send data.  DI is the data sent to the motor and RD is data from the motor.

you will also need to know the method of data transmission, is it CAN BUS, MOD BUS or some other?

okmn

Don't worry too much about the circuit diagram, I drew it quickly and gave it ... but I fixed it now, don't let those who see it learn it wrong.

no mod bus or can bus

it is simple RS-485 TTL level interface uart