Itsme
Hi,

i want to control the on board led of an arduino due.

I found a mapping of pins to physical addresses, but the pin for the led (D13 or PB27) is not listed.

How do i control the led with OpenPLC, if possible?

Thanks in advance...

Regards
Reply 0 0
thiagoralves
D033A8EF-0888-4006-8255-1BB30232C077.jpeg
Reply 0 0
Itsme
Ok, as i read this, this pin is not available as a digital output. Or is there a way to use it as a digital output?
Reply 0 0
thiagoralves

https://openplc.discussion.community/post/arduino-using-analog-for-digital-inputs-12388936?highlight=analog%20digital&pid=1332938364

This is for analog input, but the concept is similar. For analog output, just use two MOVE blocks with EN pin, and place the digital coil controlling the MOVE EN. If the coil is true, it will activate the MOVE moving 65535 (that’s the highest analog value) to %QW11. If it is false it will activate the other MOVE (you can put the coil as a negated contact) moving zero to QW11

Reply 0 0
Itsme
Thanks for the info. I already thought about this, but just wanted to know if there is an easier way.

Here some further thoughts:

1. PLC runtime sets this pin to analog output and there is no chance to reset it to digital mode. Right?
2. So this would be a way to dim the onboard led. Or am i wrong here?
Reply 0 0
thiagoralves
1. Yes, but it will require you to edit your board hal file at OpenPLC_Editor/editor/arduino/src/hals

2. Yes
Reply 0 0
Itsme
Ok, the hal file and the corresponding cpp files are used to configure the PLC. I guest the connection between HAL and CPP file is just the naming convention. Correct?

To setup an own PIN out for my needs - eg. more digital in / out and less analog pins - i would have to create an own HAL file and a corresponding CPP file in the directory. Would this be sufficient? Or would i have to do some sort of redefinition on the board it self?

And since I didn't mention yet: OpenPLC is a real nice peace of work. Thank you...
Reply 0 0
thiagoralves
You do not need to create another file. Just edit the .cpp file that is already there. You don't need to touch .hal files, they are not used anymore. There is a master hal file for all boards. Since you are not adding a new board, just changing a board that already exists, you can just edit the .cpp file for your board. Just keep in mind that all changes you make on the editor are going to disapear if you update the editor (file -> check for updates -> update). That is because the update replaces the entire editor folder with the newer version from GitHub. So if you want to keep that, make sure you copy your .cpp file to another place so that you can revert your changes back after updates.

Itsme wrote:

And since I didn't mention yet: OpenPLC is a real nice peace of work. Thank you...

Thank you! 😁
Reply 0 0
Reply