kf4pmy
I have been trying to set-up OpenPlc for a school project and personal use. Software wise I have everything running correctly. Now with trying to run the HelloWorld project, I have been getting real screw results, input / output constantly being on and cant get them to change state. After looking everything over and over again, finally digging more thru the site I believe my problem is Im not using pull down resistor on ix0.0.

This now has me wondering a couple things. For the first 2 input, I will new a pull down resistor on the switch I use and then a pull up for the remain input, correct.. Seeing at this moment Im only planning on using leds on the output side do I need pull up or down resistor on them also??

Thank, you for the help and this project. This has me digging and learning more than just PLC.

Jason Hopkins
Reply 0 0
KrisJeff
Inputs IX0.0 and IX0.1 are inverted.
Kris Jeffery.
Reply 0 0
thiagoralves

Jason, you should read a bit more about pull up/down configurations. Wikipedia has a really nice article about that. You should not connect pull down to IX0.0 and IX0.1 on the Raspberry Pi. These inputs have built in pull ups on the board. If you connect pull downs externally to them, you will end up creating a voltage divider. Not good. 

Instead of doing that, just invert your logic, or use another input besides IX0.0 and IX0.1

Reply 0 0
kf4pmy
I am for sure going to read up more on the pull down / up resistors. On that note I do have a update and question.

Update is I am pretty sure I pooched the gpio pins on 2 of my model b's, plus had a bad SD card. No matter what I have tried or done, when I run gpio readall Pins 3, 5, and 7 are always high. I cant get Hello world program to work.

So, I have now created a fresh install on my pi3 model B v1.2. I have not installed OpenPLC on it yet and I have never plugged anything into the gpio pins. WHen I run gpio readall, I show pin 3, 5, 27, 29, 31 high along with pin 10, 24, 26, and 28. Is this normal or do I have something setup wrong. Under Raspi-conf, I have everything under interfaces disabled.

Really starting to think the gremlins from work are following me home.

Jason Hopkins
Reply 0 0
thiagoralves
Hey Jason, if you want to start playing around with electronics, you must first learn how to better entertain the gremlins... 🙂

Anyway, reading GPIO pins that are not connected to anything is pretty useless because, well, the pins are not connected to anything! What would you want to be the expected outcome? Would you like them all to read zero? Not quite, because they are not connected to ground. Should they read one instead? Wrong also, because they are not connected to 3v3. So what’s the meaning of your reading then you ask? It’s noise. They will pick up whatever state, one or zero, randomly, based on the noise of your environment, just because the pins are not connected to anything. That’s why pull ups and pull downs are important, because they make sure your pins will read either zero or one if they are not connected to anything, instead of capturing noise. And that’s why I said at the beginning that you should read more about those, because they are the fundamental building blocks of any IO you could build using electronics.

The easiest way to make an experiment on this is to install OpenPLC, and then upload a useless program (make it sum two integers), but then add on your program a list of variables attached to all raspberry pi inputs (%IX0.0, %IX0.1, %IX0.2...). Once your program is running, open the monitoring tab and you will see the state of your inputs in real time. You will see that just by touching the gpio header with your fingers, some inputs will change state. That’s noise. Then if you place a wire connecting any input directly to ground, it will stay zeroed forever, until you disconnect the wire.
Reply 0 0
kf4pmy
Well, I have to say Thanks for all the help, first and for most. Like I said in my very first post this is a personal project that has turned into a school project, cause my instructor saw it and told me to run with it cause he was interested in it as a learning tool to challenge students like me who breeze thru normal class labs.

This project goes a lot deeper than the normal plug-n-play fixes we do at work, and Im enjoying the frustration. I'm sure I will have a lot of reference notes by the time Im done with this cause Im learning at my age I have to keep more and better notes unlike my apprentices who feel they can remember it all. 

I am getting a lot closer to success, after rereading the post, few older posts and double checking my wiring. I found a issue in my wiring and the switch I was using, which got me to see Ix0.0 working correctly now, still not getting my led to work but I also think I did something to screw up my copy OpenPLC again. I thinking this cause under monitoring I was showing true for everything and no change in state, stop the plc and restart it everything started showing false. So Im reinstalling everything and thinking about buying a new sd card, all the one I am using are pretty old and are normally getting bounced between 3dprinter so they have alot of use on them.

So, again Thanks for the Help and this project in general. Im getting a lot more out this than a normal day at work and school. This got me going a deeper into things, which I prefer over the plug-n-play fix's we do anymore in the Maintenace field.
Reply 0 0
NWT.Stuff
As Thiago states it's important to get our heads around the fundamentals of Input & Output pins 🙂

I use a little "trick" on my systems which has always helped me solve problems quicker.

I don't use the OpenPLC default mapping (as my standard GPIO layout was defined before I discovered OpenPLC). So in my case GPIO7 (Pin 26) is always my first input (ix0.0). Pin 25 is a GND connection so I place a link between Pin 25 & 26 (see below).

RPI-Healthy-Link.jpgI configure the Input as PULL DOWN and this gives me signal which I call RPI Healthy.  If I don’t have this signal then I know any problem I have is not a pin wiring issue.

Using OpenPLC Default Mapping I can see that %IX0.1 (Pin 5) is opposite a GND Pin 6.  So if I was starting out with Open PLC I would place my link between Pins 5 & 6 to get my RPI Healthy Signal on %IX0.1.

Kevin

Reply 0 0
kf4pmy
Gentleman,

 I hope I'm not being annoying, but with as much stuff that I am picking up things are still not working for me. I am at the  I'm truly not sure what or were my problem lies. So, here is where I am at :

1. Fresh install of raspbian os and openplc on a pi 2 model b
     (I did catch a comment during the install about a pip link no longer working and to try a different location. I unfortunately cant give better description cause I cant find my scratch pad that I wrote the information on.)

2.Updated wiringpi from v2.50 to v2.52. Going thru varies messages in the forum I saw a lot of comments about doing this, most were for pi3 and above, but at this point  I grasping at straws.

3. Uploaded a simple one input  and output program. I am using I0.3 and Q0.2. With the plc running, monitoring is show false for both. When I push my push button, I still show false.

4. I still have monitor and keyboard on my pi, so from the desktop I open a terminal screen and use gpio readall command. That screen shows I have the button pushed, but Q0.2 (physical pin 16) is still show 0

5. Stopping the program and log out, this is from my laptop. I go over to the pi itself and use gpio blink 4 (physical pin 16). First time, no good i put the led in wrong. corrected the issue and led will blink.

From my pi, I am running a ribbon cable into a breakout board from adafruit that I have plugged into a bread board. I tried what Kevin from the last reply said, but Im using a led instead of a jumper going I0.01 (pin 5) to ground and the led is on. Cause I have issue with other project using a wireless mouse, the mouse and keyboard attached to the pi are connected to a usb hub and my wifi dongle is in the other usb port the pi. 

I do have some jumper wires coming in tomorrow so I can eliminate the breakout board. This will also allow me to try this on my pi3 if necessary, But with being a industrial mechanic for last 20 yrs, 15 of it been working on Calendar lines using Siemens for the controls I have either pooched something or I am looking over something very small and obvious. This is what my gut is telling me.

So, if I have not labeled myself as a total noob that is asking the wrong questions and just needs to be left in the corner to chasing his  own tail. I really appreciate it if someone might notice what I am missing and give me a area to looking at. Even thou I am frustrated I am enjoying this cause it a deeper look into things that we dont get that deep into at work and  this has been more challenging than all the classes I have been taking for my Industrial electrical cert and automation / robotics cert.

Once again, thanks for all the help that has already been giving to me and anymore that I may get. Cause once I am comfortable with the doing basic thing with this and move on to setting up slaves or working with other aspect like modbus I'll have a lot more reading and learning to do.

Jason Hopkins
Reply 0 0
NWT.Stuff
Hi Jason,

OK in summary you have proved that wiring is correct using gpio tools.  Your problem is that when running the plc program ix0.3 and qx0.2 are permanently false.

Have I understood your problem correctly ?

Can you please attach the plc program that you are using to the post.

Kevin
Reply 0 0
NWT.Stuff
Hi Jason.

In any case I would start with your inputs.

In your Main Routine Map out the entire Input range

2021-03-10 PLC Inputs.jpg 
There is no need to have any ladder logic to monitor the Inputs as shown below:-
2021-03-10 PLC Inputs Monitor.jpg 
Now when you get you're jumper leads test each input on your breadboard.  From memory default config for inputs ix0.2 to ix0.7 is PULL DOWN so for example if you connect ix0.2 (pin 7) to RPI Ground you should get a value of TRUE.  When you remove the link the monitor should return to FALSE.

To test ix0.0 (Pin 3) and ix0.1 (Pin 5) connect a jumper lead to RPI 3V3 (Pin1). 

I would test all the inputs from ix0.2 to ix0.7 like this. If this works you would now have confidence that each pin with a good test result is working.

Hope this helps.  Kevin  

P.S. Actually I am not sure now if the default build has Inputs ix0.2 to ix0.7 as PULL_DOWN or PULL_UP.  Maybe Thiago will clarify. In any case it is important to find out what the PLC is expecting i.e.
- If Input is configured PULL_UP - link 3V3 to Input Pin
- If Input is configured PULL_DOWN - link GND to Input Pin

Once you have success and confidence I would then try the switch to drive the Inputs
Reply 0 0
thiagoralves
Actually it is the other way around. If the input has a pull up resistor, or is internally configured with the PULL_UP flag, it means that the input will always be true. So connecting it to 3v3 will basically not change anything, because the pull up resistor is already connecting it to 3v3. In this case you should connect the pin to ground, and then the input reading will go to false. Same goes for PULL_DOWN inputs, you need to connect the pins to 3v3 to see a change.

With that being said, OpenPLC on the Raspberry Pi is configured with the PULL_DOWN flag on all inputs except %IX0.0 and %IX0.1. For these two inputs, there is no pull up/down configuration in software, as the Raspberry Pi has a hardware pull up connected to these pins on the board. There is no way to change that, unless you desolder the resistors on the board.
Reply 0 0
kf4pmy
Thank, for the help, Gentleman. Greatly, cause like I said in my last post the problem is something small. 

That something small is I have been using a 40pin breakout chart as reference for a pi with 26pin header. Thank you, Kevin for the suggestion on testing input. Thats what made it register what was going on.

So,, I now will have a long night figuring out what pins are for what and  I can demostrate this to my Instructor tomorrow. Or make my life easier and steal my pi3 from another project to use for this.

Thanks again..
Reply 1 0
NWT.Stuff
Glad you found the root cause.  That would have confused the hell out of me too 🙂
Reply 0 0
Reply