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: 284 times
Been thanked: 412 times

Re: RS485 example

Post by chipfryer27 »

Hi

If your clocks are correct you wouldn't really need "debounce" as:-

You "test" and obtain a key press value, you send this value and you then wait for one second before "testing" again.

If your clock was fast, that 1S delay may only be tens of mS.

I always start by creating a one-second flash test if unfamiliar with a clock.

However as your Proteus chart is constantly transmitting but your FC isn't, I'd still focus on Proteus.

- - -

Si sus relojes son correctos, realmente no necesitaría "antirrebote" ya que: -

Usted "prueba" y obtiene un valor de pulsación de tecla, envía este valor y luego espera un segundo antes de "probar" nuevamente.

Si su reloj era rápido, ese retraso de 1S puede ser solo de decenas de mS.

Siempre empiezo creando una prueba de flash de un segundo si no estoy familiarizado con un reloj.

Sin embargo, como su carta de Proteus se transmite constantemente pero su FC no, todavía me concentraría en Proteus.

Regards

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

Re: RS485 example

Post by chipfryer27 »

Hi

Following on from above, in FC the chart you posted doesn't constantly transmit. The component itself

Waits for key press
Gets value
Waits for key release

The only way it can then branch to actually send the value is if the value is less than 16 (0x10).

I don't use Proteus so can't really advise with it, but are you sure the connections are all correct and it is simulating at the correct speed? I would definitely check the speed by creating a one-second flasher in FC and trying that in Proteus.

It would at least eliminate speed as an issue.

Regards
- - -

Siguiendo con lo anterior, en FC el gráfico que publicaste no se transmite constantemente. El componente en sí

Espera a que se presione la tecla
Obtiene valor
Espera a que se libere la clave

La única forma en que puede bifurcarse para enviar realmente el valor es si el valor es menor que 16 (0x10).

No uso Proteus, así que no puedo recomendarlo, pero ¿estás seguro de que todas las conexiones son correctas y que se está simulando a la velocidad correcta? Definitivamente comprobaría la velocidad creando un parpadeo de un segundo en FC y probándolo en Proteus.

Al menos eliminaría la velocidad como problema.

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

Re: RS485 example

Post by Carmelo »

Si, las conexiones son las correctas, asi como los tiempos.

Lo que si me he dado cuenta es que cada vez que cierro el programa y lo abro, por ejemplo al día siguiente, es que se pierden en FC la configuración de pines asignados al teclado. Al abrir de nuevo el programa FC se resetean a los valores por defecto en FC los pines de filas y columnas. Por tanto para evitar este problema he cambiado la asignación de pines en Proteus de acuerdo a los pines de FC por defecto. El funcionamiento sigue siendo el mismo.

También he corregido las opciones del oscilado y las he colocado de acuerdo a la captura de imagen adjunta.

Por otra parte, y dejando a un lado la transmisión/recepción de varios valores aleatorios, he procedido a añadir nuevas funcionalidades al proyecto creando y diferenciando 2 proyectos uno para el pic Master y otro para el pic Slave. De momento parece que lo añadido va realizando lo que pretendo, salvo algún pequeño error mío que intentaré corregir con nuevas pruebas a lo largo del día e hoy y de mañana.
Attachments
cap1.png
cap1.png (33.28 KiB) Viewed 275 times
COM485_Slave.fcfx
(48.47 KiB) Downloaded 7 times
COM485_Master.fcfx
(43.9 KiB) Downloaded 8 times

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

Re: RS485 example

Post by chipfryer27 »

Hi
What I have noticed is that every time I close the program and open it, for example the next day, the pin configuration assigned to the keyboard is lost in FC. When you open the FC program again, the row and column pins are reset to the default values ​​in FC.
Similar issues to this have been found recently. Have you downloaded all the latest updates? If so it probably should be raised as a "bug".
At the moment it seems that what was added is doing what I intend, except for some small errors of mine that I will try to correct with new tests throughout the day and today and tomorrow.
Glad to hear of some progress. I'll download your charts later tonight.
- -
Lo que he notado es que cada vez que cierro el programa y lo abro, por ejemplo al día siguiente, la configuración de pin asignada al teclado se pierde en FC. Cuando abre el programa FC nuevamente, los pines de fila y columna se restablecen a los valores predeterminados en FC.
Recientemente se han encontrado problemas similares a este. ¿Has descargado todas las últimas actualizaciones? Si es así, probablemente debería plantearse como un "error".
De momento parece que lo añadido está haciendo lo que pretendo, salvo algunos pequeños errores míos que intentaré corregir con nuevas pruebas a lo largo del día y de hoy y mañana.
Me alegra saber de algunos avances. Descargaré tus gráficos más tarde esta noche.

Regards

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

Re: RS485 example

Post by Carmelo »

Yo creo que si está todo actualizado.
En buscar actualizaciones, se me indica que no hay ninguna disponible.

No es necesario, de momento que revise ninguno de los archivos de FC que adjunte en el ultimo post. Como dije hay algunos erroes que voy a corregir.
Ya mas tarde los subiré por si quiere echarlos un vistazo y comprobarlos.

Gracias por su ayuda.

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

Re: RS485 example

Post by Carmelo »

The project will consist of a pic master and another slave, each with a keyboard and 8 outputs so that the pic master controls the outputs of the slave depending on the key pressed on the master. The master will ask the slave and in the same way when any key is pressed on the slave pic, the master will activate the output corresponding to the key pressed on the slave.

I already got the slave pic to read the bytes sent by the master and according to the second byte (key pressed), the slave activates or deactivates the corresponding output associated with the key pressed.

Now I would like to implement on the slave the functionality that when the master asks for the status of its keyboard (on the slave) then the slave sends the value of the key pressed to the master, but I don't see a way to implement it .

I attach what has been done so far.
When I sent the value of byte 1 from the master, it indicated that the slave must activate outputs according to the value of byte 2 (that makes it correct)
And when the value sent is 34, the slave should respond with the value of the key pressed on its keyboard (but if I activate that block nothing works).

I suppose it must be a problem with the activation/deactivation of the control signals of the RS487 drivers.

Any suggestions?
Attachments
COM485_Slave.fcfx
(48.96 KiB) Downloaded 7 times
COM485_Master.fcfx
(43.69 KiB) Downloaded 8 times

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

Re: RS485 example

Post by chipfryer27 »

Hi

I need to look at your charts to make sure I understanding things. I'll do that later.

From what I read it seems you send a "command" to your slave and it should respond with the value of it's pressed key.

When is the slave key pressed? Is it pressed and the value stored for retrieval later, or are you hoping that the slave key is pressed exactly when the master requests?

Necesito mirar sus gráficos para asegurarme de que entiendo las cosas. Lo haré más tarde.

Por lo que leí, parece que envías un "comando" a tu esclavo y este debería responder con el valor de la tecla presionada.

¿Cuándo se presiona la tecla esclava? ¿Se presiona y el valor se almacena para recuperarlo más tarde, o espera que la tecla esclava se presione exactamente cuando el maestro lo solicite?


Regards

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

Re: RS485 example

Post by Carmelo »

No hace falta almacenar ninguna tecla.

Cuando el máster le envié 34, pregunta por el estado del teclado, y se lo debe de enviar al máster.

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

Re: RS485 example

Post by chipfryer27 »

Hi
Cuando el máster le envié 34, pregunta por el estado del teclado, y se lo debe de enviar al máster.
When the master sent him 34, he asks about the status of the keyboard, and he must send it to the master.
If I understand correctly I think you will have problems. For the slave to return a value then a key must be pressed exactly when the master asks for it. I sincerely doubt you will ever achieve that level of synchronicity.

Perhaps I misunderstood and the master is simply sending a request, then the user is notified somehow to press a key?

I'll download later and reply once I see the charts.

- - -
Si entiendo correctamente creo que tendrás problemas. Para que el esclavo devuelva un valor, se debe presionar una tecla exactamente cuando el maestro la solicita. Sinceramente dudo que alguna vez alcances ese nivel de sincronicidad.

¿Quizás entendí mal y el maestro simplemente envía una solicitud y luego se le notifica al usuario de alguna manera que presione una tecla?

Lo descargaré más tarde y responderé una vez que vea los gráficos.

Regards

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

Re: RS485 example

Post by chipfryer27 »

Hi

Just going through your chart now.

In your Master it appears that in your settings you have the Watchdog Timer enabled.This will force your chip to keep resetting when the period expires unless you check the Auto-Clear Watchdog too. The WDT is a handy feature if needed and a pain if forgotten :)

I don't think it will work as you hope as it does look like you are trying to receive a reply from your slave without knowing exactly when it will appear. Usually an interrupt would be enabled set for RxInt so that whenever anything was received the chart would branch immediately to process.

I'll reply more later, bit busy just now.

- - -
Estoy revisando su gráfico ahora.

En su Master parece que en su configuración tiene habilitado el temporizador de vigilancia. Esto obligará a su chip a seguir reiniciándose cuando expire el período, a menos que también verifique el temporizador de borrado automático. El WDT es una característica útil si es necesario y una molestia si se olvida :)

No creo que funcione como esperas, ya que parece que estás intentando recibir una respuesta de tu esclavo sin saber exactamente cuándo aparecerá. Por lo general, se habilitaría una interrupción configurada para RxInt para que cada vez que se recibiera algo, el gráfico se bifurcara inmediatamente para procesar.

Responderé más tarde, estoy un poco ocupado ahora.


Regards

Post Reply