martinpolu
Hi, I have problems using arduino analog outputs. I'm just starting out and I just want a lamp with a timer to turn on. If I put type "int" it says "Incompatible data types for ': =' operation.". Does anyone have a small example? Thank you
Reply 0 0
thiagoralves
You don't need analog outputs to work with timer. Analog outputs would be used in this example to turn the lamp with half of its bright or so. What you need is exactly the hello world example from the getting started guide: http://www.openplcproject.com/getting-started-arduino
Reply 0 0
martinpolu
Hi, i need to use analog outputs because my PCB is already done!
Reply 0 0
thiagoralves
This doesn't make any sense... Can you share your program so that I can have a better picture of what you're trying to do?
Reply 0 0
martinpolu
AnalogOutput.png 
Codigo.png  Error.png 
Reply 0 0
thiagoralves
There are a few mistakes in this program. First, the addresses for the analog I/O for the Arduino board is wrong at the website (I'm sorry, I need to fix this). There is no such output as %QW0.4. For all analog I/O you need to drop the "0.", becoming just %QW4. Discrete I/O still has the "0." addressing (i.e. %QX0.3) because the first number means the byte position and the second number after the dot means the bit location in the byte. This doesn't make sense for multi-bit variables such as analog I/O.

Second, a coil is a binary variable. You're trying to associate an integer with a coil, and that's why you're getting the "incompatible data type" error. I believe that what you're trying to do is to turn on the %QW4 output. However, since it is an analog output, it won't just turn on or off. Analog variables deal with quantities, therefore you need to send a number to this output, in the range 0-65535. If you send 0, the output will be completely off. If you send 65535 the output will be completely on. Anything in between means that the output is partially on or off. If you want to treat this as a binary on-off output, a good way to do that is to use the MOVE block. Just enable the "Execution Control" checkbox on the MOVE block so that the operation is conditional. Then you can connect a button to it so that when the button is pressed it will move 65535 to my lamp on %QW4. When the button is not pressed, by default the block is disabled moving 0 to %QW4. Well, a picture is worth more than a thousand words:

Capture.PNG 
Reply 2 0
manu_plc
Hi
i am trying to use Openplc with an Arduino Uno and i see that the PWM output location is %QW0 and not %QW0.0.
but when i upload my code there is nor error  ? And when i debug everything is ok?
May something to fix ?
My question with arduino Uno analog inputs the addressCapture d’écran_2023-12-28_17-12-32.png of location is %IW0 or %IW0.0 ?
thanks a lot for this open source project
Reply 0 0
thiagoralves
Reply 0 0
manu_plc
Thanks a lot y see where is my mistake.
But for arduino mega on physical adderssing i see somthing wrong
the input %IX0.0 to %IX0.7 are pins 62 to 69 ????
it seemes to me inexact because theses pins dosent exit on adruino méga .
there are A9 to A15 analog input witch are not used ?
I wanna make à board whith a mega and i wanna be sure for the address.
 
 
Capture d’écran_2024-01-07_03-53-30.png
Reply 0 0
thiagoralves
IMG_0441.jpeg
Reply 1 0
manu_plc
Ok thank you
Another question quickly can i use hexadecimal notation for variables ?
I  try 0xFF,FF H FF nothing seems working? Only decimal values are usable?
I have worked with old PLC languages (before the IEC 61131-3 standard...) PL7.2 PL7.3
for TSX47, TSX17 or PB15 ...
other question can i affect a byte to a group of output ( i wanna try to use a LCD alphanumeric
porogrammmed with ladder).ar-afficheur-2x16-caracteres-ld1602zfa-21035.jpg
My knoledge of programming PLC is not up to date.
Reply 0 0
thiagoralves

A prefix of 2#, 8#, or 16# is used to signify binary, octal or hexadecimal integers. For example:

2#1010101 is the binary representation of 85,
8#707 is the octal representation of 455, and
16#FFFF is the hexadecimal representation of 65535.

Source: https://www.fernhillsoftware.com/help/iec-61131/common-elements/literals-numeric.html
 
There isn't a block to convert a byte to 8 bits, but if you know some ST language you can easily write such block yourself.
Reply 1 0
manu_plc
Ok ST language it is for latter for me.
my well known langage is C and asembling laguage with PIC microcontrolers.
thank you very much!
Reply 0 0
manu_plc
A great thank you for the source
ST language seems very interessting to make code like  my C arduino projects.
Just have time to understand differneces with C and ST laguange (syntax etc etc...)
Sorry for my poor english....😌
Reply 0 0
Reply