Vlak
Hi everyone, I want to write a ladder program to read a potentiometer and adjust it if necessary. I have no idea how to approach this or which function blocks to use. Can someone provide an example?Hi everyone, I want to write a ladder program to read a potentiometer and adjust it if necessary. I have no idea how to approach this or which function blocks to use. Can someone provide an example?
Reply 0 0
thiagoralves
You need to first wire your potentiometer to the analog input of the hardware device you're running OpenPLC on. Then, to read the analog input, just create a variable type UINT and locate it in one of the analog input locations (ex: %IW0, %IW1, %IW2). The value read will be proportional in the 0-65535 scale, where 0 is minimal reading and 65535 is maximum reading. You can then use this variable anywhere in your program to make comparisons, take decisions, calculate values, etc.
Reply 0 0
Vlak
Thanks for your simple answer. It works so far, but lately I've been having trouble uploading the program more often, seeing an error. Any ideas?
 
 
[203128%2F9512103%2Fmceclip0]
Reply 0 0
thiagoralves
Make sure you've selected the correct COM port and that it is not in use.
Reply 0 0
Vlak
I managed to get the program in and use the values ​​from my potentiometer. I'm still wondering why it sometimes fails to connect to the Arduino. Very strange.
 
[203128%2F9512706%2Fmceclip0]
Reply 0 0
Vlak
Are there also encoders that can be used for the same principle?
Reply 0 0
thiagoralves
No, encoders use digital pulses to count position. You will need a dedicated hardware to read them. You can use a PLC that supports reading encoders (like P1AM for example) and then you can use the read encoder value in a similar way
Reply 0 0
Vlak

Rotary Encoder HW-040

 
 
 
[203128%2F9512721%2Fmceclip0]
Reply 0 0
thiagoralves
That's correct. You will need a dedicated hardware to read something like this, even if this dedicated hardware is an Arduino Uno board. The PLC scan time is too slow to read pulses accurately.
Reply 0 0
Sarel Erasmus
Good evening hope everyone is doing well, could anybody assist me on creating a digital potentiometer using Ladder Language? I am new to the open plc and I don`t want to struggle using a hardwired potentiometer.
Reply 0 0
Rod
You need to first wire your potentiometer to the analog input of the hardware device you're running OpenPLC on. Then, to read the analog input, just create a variable type UINT and locate it in one of the analog input locations (ex: %IW0, %IW1, %IW2). The value read will be proportional in the 0-65535 scale, where 0 is minimal reading and 65535 is maximum reading. You can then use this variable anywhere in your program to make comparisons, take decisions, calculate values, etc.

How can I connect the potenciometer in the in *main, should i use a block, a coil or a contact, and how can I configurate it.

[203128%2F9915226%2Fmceclip0]

Reply 0 0
thiagoralves
Hello,
The OpenPLC forum has a new home: https://edge.autonomylogic.com . We migrated every member, profiles, topics, categories and attachments. Please redo your post on the new forum so we can continue our conversation.
Note: If you already have an Autonomy Edge account, you can simply login with your credentials to have access to your forum profile and posts. If you don't have an Autonomy Edge account, we ask you to set a fresh password on first sign-in using the same e-mail you used on this forum.
To set a fresh password, access the link https://edge.autonomylogic.com/forgot-password and insert the e-mail address used on this forum. You will receive an e-mail on your inbox with a link to choose a new password. Once you reset your password you will be able to login onhttps://edge.autonomylogic.com using your new credentials.
Reply 0 0
Reply