RS485 example

Use this section to discuss your embedded Flowcode projects.
chipfryer27
Valued Contributor
Posts: 1147
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 285 times
Been thanked: 412 times

Re: RS485 example

Post by chipfryer27 »

Hi

The problem appears to be that you are using a String as the array.

If you look at Simulation Debugger and have your array as one of the variables to display, you will see that things are fine until you get to certain values which correspond to certain characters / action.

If you create a byte array and populate that then you should be good.

Unrelated, I notice that you are setting each bit of an output byte individually to display a value on the LEDs. An easier way may be to use an LED array and just write the value to it?

I've attached a modified file.

COM485_Modified.fcfx
(19.73 KiB) Downloaded 10 times

Let me know if this helps

Regads

Carmelo
Posts: 42
Joined: Thu Oct 14, 2021 10:04 am
Has thanked: 14 times

Re: RS485 example

Post by Carmelo »

Gracias de nuevo por la respuesta.
Cambie lo indicado en la definición del array y en el depurador de Flowcode si hace lo que se le pide.
Lo que sucede es que ahora en los "virtual terminal" no veo los valores que se deben de enviar. Ejemplo 03 para el byte 1 y el valor de la tecla pulsada para e el byte 2.
Siempre envía la misma secuencia F0 00 00 00. Ahora envía 4 bytes si corresponder ninguno con el valor a enviar, ejemplo 03 01.

Cierto lo de los leds solo era una prueba para ver la tecla pulsada de forma física. Esa parte se cambiará posteriormente.
Attachments
CAPTURA.png
CAPTURA.png (136.07 KiB) Viewed 195 times

Carmelo
Posts: 42
Joined: Thu Oct 14, 2021 10:04 am
Has thanked: 14 times

Re: RS485 example

Post by Carmelo »

Por si se necesita para comprobación adjunto también el fichero de Proteus.
De momento, para ir comprobando, solo necesito el enviar y recibir los 2 bytes del programa de Flowcode.
Tambien el proyecto FLowcode corregido.
Attachments
COM485.fcfx
(40.14 KiB) Downloaded 9 times
COM485_Flowcode_18F25K50.rar
(222.79 KiB) Downloaded 7 times

chipfryer27
Valued Contributor
Posts: 1147
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 285 times
Been thanked: 412 times

Re: RS485 example

Post by chipfryer27 »

Hi

It simulates fine in Flowcode. If you look at Simulation Debugger and display the variable Key, it will show the array values.

If you look at the console data View > Consoles and click on UART1, you will see what is being transmitted by the UART. All good there too.

I see you are using Proteus so perhaps the issue is with it?

- - -

Simula bien en Flowcode. Si observa el Depurador de simulación y muestra la variable Clave, mostrará los valores de la matriz.

Si observa los datos de la consola Ver> Consolas y hace clic en UART1, verá lo que transmite la UART. Todo bien ahí también.

Veo que estás usando Proteus, entonces ¿quizás el problema esté en él?

Regards

Carmelo
Posts: 42
Joined: Thu Oct 14, 2021 10:04 am
Has thanked: 14 times

Re: RS485 example

Post by Carmelo »

Gracias nuevamente por la respuesta.

Si ya veo en el depurador y en la consola que se transmite todo bien. El problema es que a la salida del terminal Tx del pic dentro de Proteus, se ve actividad pero lo que lee el virtual terminal no se corresponde con los valores que está enviado Flowcode.

Ciertamente puede ser error de Proteus, pero lo que me desconcierta es que tengo un programa similar realizado con otro software y Proteus está leyendo bien lo que se le manda por el pin Tx del pic.

Me gustaría pasar el proyecto funcionado con el otro software a Flowcode, pero veo que hay algo que les hace funcionar de forma diferente y eso me desconcierta porque no entiendo porque.

Seguiré investigando a ver que puede estar pasando.

chipfryer27
Valued Contributor
Posts: 1147
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 285 times
Been thanked: 412 times

Re: RS485 example

Post by chipfryer27 »

Hi
Thanks again for the response.

Yes, I already see in the debugger and in the console that everything is transmitted fine. The problem is that at the output of the Tx terminal of the pic within Proteus, activity is seen but what the virtual terminal reads does not correspond to the values ​​that Flowcode is sending.

It could certainly be a Proteus error, but what puzzles me is that I have a similar program made with other software and Proteus is correctly reading what is sent to it through the Tx pin of the pic.

I would like to transfer the project running with the other software to Flowcode, but I see that there is something that makes them work differently and that baffles me because I don't understand why.

I will continue investigating to see what may be happening.
- - -

Not sure if I have that chip, but I'll try in Hardware using a PIC when I get the chance. I'm always "wary" of relying on 3rd-party software to explain operation :)

- - -

No estoy seguro de tener ese chip, pero lo intentaré en Hardware usando un PIC cuando tenga la oportunidad. Siempre soy "cauteloso" a la hora de confiar en software de terceros para explicar el funcionamiento :)

Regards

Carmelo
Posts: 42
Joined: Thu Oct 14, 2021 10:04 am
Has thanked: 14 times

Re: RS485 example

Post by Carmelo »

Entiendo su proceder,

Se que Proteus hay veces que no funciona como debiera, pero en este caso, tan simple, no entiendo porque con un software si funciona y con otro no .
Ese es mi problema, lo sé pero me gustaría saber porque hace eso, así intentaré seguir investigando.

chipfryer27
Valued Contributor
Posts: 1147
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 285 times
Been thanked: 412 times

Re: RS485 example

Post by chipfryer27 »

Hi

I will let you know what I find using Hardware, but that will be later in the week

- - -

Les haré saber lo que encuentro usando Hardware, pero eso será más adelante en la semana.

Regards

Carmelo
Posts: 42
Joined: Thu Oct 14, 2021 10:04 am
Has thanked: 14 times

Re: RS485 example

Post by Carmelo »

Muchas gracias por su atención.

Estaré al tanto de sus noticias

LeighM
Valued Contributor
Posts: 401
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 70 times
Been thanked: 217 times

Re: RS485 example

Post by LeighM »

output of the Tx terminal of the pic within Proteus, activity is seen but what the virtual terminal reads does not correspond to the values ​​that Flowcode is sending.
A baud rate issue?
Is the PIC clock setup ok?

Post Reply