Is it possible to have an internal pull-up on the Programmable Digital I/O pins on the Portenta Machine Control PLC?
I need to use these ports for switch detection and would prefer to have 24V internal pull-up.
If yes, what is the syntax?
Does " digital_programmables.set(IO_WRITE_CH_PIN_03, SWITCH_ON);" effectively pull the pin up and does shorting it to ground and then reading it with "digital_programmables.read(IO_READ_CH_PIN_03))" short out the input, potentially damaging the circuitry?
Can someone please post ALL the commands necessary to read for example, Pin DIO03?
-
Is it possible to have an internal pull-up on the Programmable Digital I/O pins? Yes
-
I need to use these ports for switch detection and would prefer to have 24V internal pull-up. No you need to use external hardware.
-
Does " digital_programmables.set(IO_WRITE_CH_PIN_03, SWITCH_ON);" effectively pull the pin up and does shorting it to ground and then reading it with "digital_programmables.read(IO_READ_CH_PIN_03))" short out the input, potentially damaging the circuitry? Yes you are shorting the port pin output causing it to draw an excessive amount of current. Try it and wait a bit and the manic smoke may appear.
-
Can someone please post ALL the commands necessary to read for example, Pin DIO03? You have a great tool, called a search engine, there are many examples on line.
I highly recommend you get a copy of the Arduino Cookbook, what you want to do I believe is in there.
Thank you for replying .
1/ How?
2/ As your answer to 1/ is 'Yes' then why do I need external hardware?
3/ I had formed the opinion this would short it, hence the question for confirmation.
4/ Unfortunately, telling me to search doesn't help. I have searched for weeks for this information and have not found it! I have a copy of the Arduino Cookbook but it was written before the Portenta H7 was invented!
I have used pullups on Uno, Nano, Mega etc for years and is no problem but I cannot find anything anywhere that mentions using them on the PMC.
That is why I have come to the forum to ask for help.
I would suggest you do some tutorials on basic electronics. Nice to tell us what micro you are using.
- Your search engine may need repair. I searched for "Arduino pull up", this was my first hit out of 11,800,000 results. https://docs.arduino.cc/tutorials/generic/digital-input-pullup
- Read the rest of the answer. Try this search, hopefully it works: arduino input high voltage
3.+
4. I will give you a big secret, unless specially designed micro processors will only tolerate a voltage up to VCC + about 0.5V, depending on process. If you exceed that the protection diodes start conducting to VCC. If that rises it will go to the point the processor will destroy itself. If it does not the internal diode will start to get warm and eventually destroy that portion of the microprocessor or more, not predictable with out knowing all the conditions.
Great you have the cookbook, read it, it is still over 95% correct. Just because it rained a few days ago does not tell you it will be raining today.
@gilshultz I dont understand why you have bothered to reply. I was taught "If you can't say something nice, don't say it!" and that very much applies to your answer! You obviously do not know anything about this particular Arduino product (The Arduino Portenta Machine Control - PLC) and so you reply with sarcastic and unhelpful products.
Please do not reply again and instead leave the replies to someone who a) knows this product and b) is actually willing to offer assistance.
@gilshultz please do not bother to reply.
Hi @gadget12 ,
I am using the PMC's Programmable Digital IO as Digital inputs. The following code reads the PD03 pin every 5 seconds and displays the output to Serial. If 24VDC is applied to the pin the output is 1, if not the output is 0.
#include <Arduino.h>
#include <Arduino_MachineControl.h>
#include <Wire.h>
using namespace machinecontrol;
int readInterval = 5000;
int readTimer = 0;
void setup() {
Serial.begin(115200);
unsigned long startSetup = millis();
while (!Serial) {
// Time override: 5 seconds
if (millis() - startSetup > 5000) {
break;
}
}
Serial.println("Programmable IO Demo");
// Start wire - required for digital_programmables
Wire.begin();
// Programmable Digital input init
if (!digital_programmables.init()) {
Serial.println("Digital IO Error");
}
}
void loop() {
if (millis() - readTimer >= readInterval) {
readTimer = millis();
int DP03 = digital_programmables.read(IO_READ_CH_PIN_03);
Serial.print("DP03: ");
Serial.println(DP03);
}
}
I hope that helps!
Thank you for that!
Now that I understand the PMC uses 24V Logic and allows 'pull-down' I have got that part working.
The next issue is weird behaviour on the Digital Input pins when using the USB/Serial Monitor but that will be a new question!
@ [thebeest], I just tried your code - nothing happened. I am definitely switching +24V on the pin but no response on the Serial Monitor - it just shows typically: 23:41:31.685 -> DP03: 0
Any suggestions?
HI @gadget12 ,
Maybe you have an issue with ground, can you confirm you have got the PMC wired up like this?
Note: The black dashed line is optional but good practice.
When I tested the above code I had the PMC wired up like that and the code worked as expected. Fingers crossed that does the trick!
Sorry for the slow response - I have been on a holiday!
Yes, I can confirm it is wired as shown,
No worries. You might have to contact Arduino support as I have tested the code with that exact wiring and our results should be the same. Maybe you have a faulty board.
