Codesys - Convert byte to outputs

kallamamran

Member
Join Date
Dec 2016
Location
Gothenburg
Posts
7
Hello experts :)

I'm new to Codesys (3.5) and I am trying to make a program which takes a number 1-50 (read from some tags UID) and outputs each bits status to output %QX1.0 - %QX1.7 :confused:

Can anyone please help? I know it should probably be quite easy, but I just can't find out how... 🤞🏻

Best regards // Johan
 
I am not a 100% sure about this, but lets assume your number is in memory %MW0, have you tried moving that directly to your output? QW0 := MW0?

If that won't work. Can you access the bits in MW0 individually by using MX0.0?
 
I am not a 100% sure about this, but lets assume your number is in memory %MW0, have you tried moving that directly to your output? QW0 := MW0?

If that won't work. Can you access the bits in MW0 individually by using MX0.0?

Hi boneless,

I have not tried that. I do have the read value in a variable and was thinking about using that to configure the output.
I am actually programming at home now without access to the hardware, so I'm trying to get as much info and as much done as possible before going back into office tomorrow.
I'm sure there's a way to extract the boolean value of the bits to use for the outputs and I really hope you're correct. That would save me a lot of time :)
 
Did you know you can set up a Raspberry Pi to run CodeSYS? That would be a great test bed for home use :).

Let us know if it works and welcome to the forum!
 
Did you know you can set up a Raspberry Pi to run CodeSYS? That would be a great test bed for home use :).

Let us know if it works and welcome to the forum!

:) I actually do know or have heard of that. Wouldn't help me much right now though since I would have to fit the program to the hardware at work afterwards anyway :)

And thank you (y)
 
oscat is in english and download the codesys version the manual and also download the text version, that way you have a very nice manual and how it is programmed. It is all open.
 
Hi kallamamran,

You can use a bit of the byte by declaring it like this:

By example;
Your variables
Test_byte : Byte ;
Test_output1 :Bool;

Programm
Test_output1 := Test_byte.0 ;
Test_output2 := Test_byte.1;
etc...

The dot and number identified the number of bit of the byte you want to use.

Hope that help you.
 
Hi kallamamran,

You can use a bit of the byte by declaring it like this:

By example;
Your variables
Test_byte : Byte ;
Test_output1 :Bool;

Programm
Test_output1 := Test_byte.0 ;
Test_output2 := Test_byte.1;
etc...

The dot and number identified the number of bit of the byte you want to use.

Hope that help you.

Thank you! :) Makes perfect sense with whats stored in the back of my head from when I attended a short course several years ago (y)
 
You can simply declare what byte or word you want to control the outputs in the "I/O mapping list" of the output interface. No need to write any code.
 

Similar Topics

Hello, I am new to Codesys 3.5 and I am trying to figure out how to convert a word into 2 bytes to send to another plc via ethernet/ip. Could...
Replies
5
Views
5,101
Hi, It's been a while since I've been doing PLC work as I've been concentrating on a large security project. However I have a TIME variable in a...
Replies
11
Views
16,288
Hello, I am using a Hitachi Micro EHV+ for a small project, and I wanted to have a Web visu, done with Codesys V3.5 SP13 Patch 2. I test the...
Replies
6
Views
304
Hello, I have a requirement to manage the text alignment dynamically. So, for example: 1. English Texts should be displayed from Left in...
Replies
0
Views
93
Hello, I am new to Codesys, and am trying to learn about it for a project we're developing. I've got a couple questions, but first a little...
Replies
1
Views
163
Back
Top Bottom