Re: Remote pump control ideas.
No, it would not, because it's not actually a single plain LED. It's THIS...which also explains why I paid no mind to resistors for the LED - it's a standalone lamp you run on 12v. It does the stuff you mention inside of it.
I WAS thinking of going straight to the MCU/schmitt pin like this, but this sends 12v into the pin when the diode becomes forward-biased (switch open) if I see it right (even with a resistor inside the lamp). It MIGHT work if running on 5v, since it would simply "pull up" the pin of the MCU/schmitt which wouldn't care...
Remote pump control ideas.
Collapse
X
-
Re: Remote pump control ideas.
wtf?
use the relay to pull to ground,
out the led & resistor(2k2) to +12v or use 5v and 470ohm or higher
the microcontroller has internal pullups
btw - your circuit will blow the led to bits - literally!Last edited by stj; 10-26-2020, 12:45 PM.Leave a comment:
-
Re: Remote pump control ideas.
Back to something slightly more hardware-related: it's a snippet of this project's schematic and I'm trying to "read" the status of the main contactor through one of its AUX contacts to signal it to the MCU, but I also want to turn on a 12v LED lamp with it. Would something like this work ? I used a schmitt-trigger there just because
Sticklers will probably point out immediately that I have a free set of contacts to the far right which I could use, but this is ASSUMING I only have the one N.O contact to work with and I need to both signal the MCU if the contactor is on/off AND turn on the green lamp. I'm not sure what happens when the switch opens...would the input of the schmitt trigger "float" and go ape$hit ?
Another idea was to use the base of a transistor there to drive the lamp (and use 5v on the AUX switch, instead of 12) but again: I'm not sure it would be "stable"...Leave a comment:
-
Re: Remote pump control ideas.
You don't need interrupts. In my example, you LIKELY would have them to provide the timing information. But, you could also implement delays using a real timer.
The point is that you can write your code largely ignorant of the fact that other "programs" (tasks) are co-executing alongside you -- assuming you take precautions not to have two (or more) trying to use the same resource(s) at the same time.
The downside to the "super loop" approach is that you have to remember to EXPLICITLY "share" the processor with the other tasks. There's a tendency to want to "be greedy" with it as it often makes the current task's job easier (at the expense of other tasks)Leave a comment:
-
Re: Remote pump control ideas.
Code:task_t winky(void) { while (FOREVER) { LED = ON; sleep(1000ms); LED = OFF; sleep(1000ms) } }
Preemptive tends to be more performant; non-preemptive tends to be safer (for newbies) as you can control when you relinquish control of the processor (to implicitly avoid atomic regions).Leave a comment:
-
Re: Remote pump control ideas.
that's not how it's done,
you have a main loop that branches to each task.
tasks like checking buttons, checking sensors etc.
none of the tasks go into a closed loop.Leave a comment:
-
Re: Remote pump control ideas.
Yeah, but can Atmels "truly" do it ?
If I'm in a while loop for instance, I can't do anything else outside that, meaning if a button changes state outside that loop, it won't catch that....Leave a comment:
-
Re: Remote pump control ideas.
that's what multi-threading is, jumping between stuff so fast that nobody can tellLeave a comment:
-
Re: Remote pump control ideas.
Another reason it went better this time is because I decided to re-write the whole code and it all became SO MUCH easier once you understand the program you write runs line by line. It makes it so much easier to understand all the whiles and DOs...it was like a stroke of geniusOk, it's unimpressive for any "real" programmer out there, but it helped clear some things out.
There's still stuff I haven't yet delved into, such as doing stuff simultaneously, which I think is called multithreading ??? This would be handy in my car window project where I have to monitor two switches independently. The way I did it works, but it's disastrous overallIt only "feels" like it does stuff at the same time - it doesn't - just does it fast enough that it feels so...
Leave a comment:
-
Re: Remote pump control ideas.
record speed compared to your AVR stuff then.Leave a comment:
-
-
Re: Remote pump control ideas.
lol
did you go to my link to check your stlink is up to date?
btw, you can move a couple of jumpers on the stlink part and use it standalone to program other stm32 chips.Leave a comment:
-
Re: Remote pump control ideas.
I finally unwrapped the STMs today and had a go with the Arduino IDE. Of course, I did the blinky-LED thing first to keep it as simple as possible. Amazingly, it worked first try: I was expecting errors up the a$$, but it actually uploaded. It took FOREVER to compile though ! No doubt it takes a lot of "work" to go through all this hacky process, plus my laptop is an old POS I keep strictly for messing around on, so that didn't help either.
I am unable to get the serial COM port to work, since I next tried using the DHCP Address printer sketch on it to see if it'd hook up and get an IP address, but I got no serial COM port to choose from to actually SEE if it did anything - it just stood there. Then I went to the list of COM ports and found nothing there, so I'm now struggling to find a driver, since from what I read online it CAN be done....
EDIT: I finally did it. Turns out there's like two different drivers: one for the ST_LINK itself and one for the STM32 "chip"........I didn't know that and kept installing the one for the chip, but not the interfaceCOM9 now shows up. It turns out it doesn't reset the board when I open up the serial monitor, so I have to do it manually using the reset button on the board - I was just sitting there like a dumbass wondering what the heck is going on, so I just hit reset and bang, my IP address showed up.....*OOOOOOOHHHH* I see
Last edited by Dannyx; 10-23-2020, 01:23 AM.Leave a comment:
-
Re: Remote pump control ideas.
Server side code
Code://SOURCE: http://www.handsonembedded.com/arduino-ethernet-shield/ #include <Ethernet.h> #include <SPI.h> byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xAA }; // Arduino Server MAC address const int port = 23; // Stores the value of the local port used to listen for incoming clients //If DHCP is not available, the following addresses will be used by default IPAddress ip(10, 11, 5, 170); // The static IP address that will be used if DHCP is not available IPAddress myDns(193, 231, 242, 2); // IP of DNS server IPAddress gateway(10, 11, 5, 1); // IP of Default Gateway IPAddress subnet (255, 255, 255, 0); // Subnet Mask EthernetServer theServer(port); // Create a sever object, name it "theServer" and have it listen on the port specified above (23) unsigned long commandTime = 0; const int debounceTime = 2000; int tankStatus; void setup() { Serial.begin(9600); // Start serial monitor if (Ethernet.linkStatus() == LinkOFF) { Serial.println("No link. Check network cable..."); //Link status check. Stop if not connected. Note that this only works on W5500 boards and is skipped otherwise ! delay (2000); } Serial.println("Attempting to obtain address by DHCP..."); if (Ethernet.begin(mac) == 0) { Serial.print("Failed to configure Ethernet using DHCP - "); //Attempt DHCP first and return this message if failed if (Ethernet.hardwareStatus() == EthernetNoHardware) { Serial.println("Ethernet module not found or faulty..."); // Check for Ethernet shield and stop if not found while (true) { delay(1); } } Ethernet.begin(mac, ip, myDns, gateway, subnet); // Switch back to static IPs (set above) if DHCP failed and print out their values Serial.print("Default IP Address is "); Serial.println(Ethernet.localIP()); Serial.print("Gateway IP is "); Serial.println(Ethernet.gatewayIP()); Serial.print("Subnet mask is "); Serial.println(Ethernet.subnetMask()); Serial.print("DNS Server IP is "); Serial.println(Ethernet.dnsServerIP()); } else { Serial.print("DHCP assigned IP is "); // Print dynamic address if DHCP was successful Serial.println(Ethernet.localIP()); Serial.print("Gateway IP is "); Serial.println(Ethernet.gatewayIP()); Serial.print("Subnet mask is "); Serial.println(Ethernet.subnetMask()); Serial.print("DNS Server IP is "); Serial.println(Ethernet.dnsServerIP()); } bitClear(DDRA, 0); // Set Digital pin 22 on the Mega as an INPUT for "RUN" bitClear(DDRA, 1); // Set Digital pin 22 on the Mega as an INPUT for "STOP" bitSet(DDRA, 2); // Set Digital pin 24 on the Mega as an OUTPUT for "MCU OK" indicator bitSet(DDRB, 7); // Set LED pin 13 on the Mega as an output for switch status delay(2000); // give the Ethernet shield a second to initialize: theServer.begin(); bitSet(PORTA, 2); //status LED } void loop() { Ethernet.maintain(); //probably good to disable if DHCP is not used??? while (bitRead(PINA, 0) == 1) //tank level is low and needs filling. ON contact is active (MCU pin is HIGH due to 74HC14 inverter) { commandTime = millis(); break; } while (bitRead(PINA, 0) == 1) { if (millis() - commandTime > debounceTime) { if (bitRead(PINA, 1) == 0) { bitSet(PORTB, 7); //check if the OFF contact is not stuck ON tankStatus = 1; break; } else { tankStatus = 2; // break; } } } while (bitRead(PINA, 1) == 1) //tank level is full and pump needs to stop. OFF contact is active (MCU pin is HIGH due to 74HC14 inverter) { commandTime = millis(); break; } while (bitRead(PINA, 1) == 1) { if (millis() - commandTime > debounceTime) { if (bitRead(PINA, 0) == 0) { bitClear(PORTB, 7); //check if the ON contact is not stuck ON tankStatus = 0; break; } else { tankStatus = 2; break; } }// } EthernetClient theClient = theServer.available(); //Get available client wishing to speak to server String commandString; while (theClient.available()) { char c = theClient.read(); if (c != '\n') { commandString += c; // Read char until linefeed, then add received char to commandString variable } else { Serial.println("Command:" + commandString); if (commandString == "POLL") { doReply(); } } } } void doReply() { if (tankStatus == 1) { theServer.print("ON\n"); } else if (tankStatus == 0) { theServer.print("OFF\n"); } else if (tankStatus == 2) { theServer.print("ERR\n"); } }
Leave a comment:
-
Re: Remote pump control ideas.
Here's what I concoctedIt works as I expect it to work. Big shoutout to STJ for giving me this idea...sort-of
There's two pieces of code: one for the hilltop tank, the other for the pump at the bottom, as previously described. The client is now at the bottom shack (the pump side). This idea allowed me to simplify the code immensely and remove A LOT of clutter.
I'm sure there's stuff which can be improved (for instance the lack of comments, which I'm aware of), but remember: this is extremely basic, suitable for your average beginner.
Client side:
Code:#include <SPI.h> #include <Ethernet.h> byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xBB }; //Arduino Client MAC address // If you don't want to use DNS (and reduce your sketch size) // use the numeric IP instead of the name for the server: IPAddress testServer(10, 11, 5, 239); // IP of the first server to poll client //IPAddress testServer2(10, 11, 5, 170); // IP of the second server to poll //char server[] = "www.google.com"; // OR name address using DNS //If DHCP is not available, the following addresses will be used by default IPAddress ip(10, 11, 5, 170); // The static IP address that will be used if DHCP is not available IPAddress myDns(193, 231, 242, 2); // IP of DNS server IPAddress gateway(10, 11, 5, 1); // IP of Default Gateway IPAddress subnet (255, 255, 255, 0); // Subnet Mask // Initialize the Ethernet client library // with the IP address and port of the server // that you want to connect to (port 80 is default for HTTP): EthernetClient theClient; //Some variables to store different stuff const int maxFailCount = 5; const int pollInterval = 5000; unsigned long lastPoll; int failCount = 0; int getStatus = 0; bool clientConnected; bool commErr; void setup() { Serial.begin(9600); // Open serial communications and wait for port to open while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } while (Ethernet.linkStatus() == LinkOFF) { Serial.println("No link. Check ethernet cable..."); delay (2000); } Serial.println("Attempting to obtain DHCP lease..."); if (Ethernet.begin(mac) == 0) { Serial.print("Failed to configure Ethernet using DHCP - "); //Attempt DHCP first and return this message if failed if (Ethernet.hardwareStatus() == EthernetNoHardware) { Serial.println("Ethernet module not found or faulty..."); // Check for Ethernet shield and stop if not found while (true) { delay(1); } } Ethernet.begin(mac, ip, myDns, gateway, subnet); // Switch back to static IP (set above) if DHCP failed Serial.print("Set static IP Address as "); Serial.println(Ethernet.localIP()); //Print static IP to serial Monitor Serial.print("Gateway set as "); Serial.println(Ethernet.gatewayIP()); //Print gateway IP to serial Monitor Serial.print("Subnet mask "); Serial.println(Ethernet.subnetMask()); //Print subnet mask to serial Monitor Serial.print("DNS Server "); Serial.println(Ethernet.dnsServerIP()); } //Print DNS Server IP to serial Monitor else { Serial.print("Obtained DHCP lease. IP is "); // Print dynamic address if DHCP was successful Serial.println(Ethernet.localIP()); Serial.print("Gateway IP is "); Serial.println(Ethernet.gatewayIP()); Serial.print("Subnet Mask is "); Serial.println(Ethernet.subnetMask()); Serial.print("DNS Server IP is "); Serial.println(Ethernet.dnsServerIP()); } delay(2000); // give the Ethernet shield a second to initialize: // You can use Ethernet.init(pin) to configure the CS pin //Ethernet.init(10); // Most Arduino shields //Ethernet.init(5); // MKR ETH shield //Ethernet.init(0); // Teensy 2.0 //Ethernet.init(20); // Teensy++ 2.0 //Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet //Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet // bitClear(DDRD, 2); // PIN 2 configured as input pin // bitSet (DDRD, 3); // PIN 3 configured as output pin // bitSet (DDRD, 4); // PIN 4 configured as output pin bitSet (DDRD, 5); // PIN 5 configured as output pin bitSet (DDRD, 6); // PIN 6 configured as output pin tone(3, 1000, 1000); //startup } void loop() { Ethernet.maintain(); if (clientConnected == false) { if (theClient.connect(testServer, 23)) { clientConnected = true; failCount = 0; } else { if (failCount < maxFailCount) { failCount++; } if (failCount >= maxFailCount) { commErr = true; } delay(1000); } } if (clientConnected == true) { pollServer(); if (getStatus == 1) { bitSet(PORTD, 5); } else if (getStatus == 0) { bitClear(PORTD, 5); } } if (commErr == true) //on comm failure light up indicator, low beep, stop pump { bitSet(PORTD, 6); tone(3, 200, 100); bitClear(PORTD, 5); } else { bitClear(PORTD, 6); //turn off indicator if connection resumes } } void pollServer() { failCount = 0; //reset fail counter on each iteration of pollServer function bool invalidResponse; do { String commandString; do { if (millis() - lastPoll >= pollInterval) { theClient.print("POLL\n"); lastPoll = millis(); if (failCount <= maxFailCount) { failCount++; } if (failCount > maxFailCount) { clientConnected = false; commErr = true; return; } } } while (!theClient.available()); while (theClient.available()) { char c = theClient.read(); if (c != '\n') { commandString += c; // Read char until linefeed, then add received char to commandString variable } else { Serial.println("SwitchStatus: " + commandString); if (commandString == "ON") { getStatus = 1; //do this if ON arrives commErr = false; tone(3, 1000, 100); return; } else { if (commandString == "OFF") { getStatus = 0; //do this if OFF arrives commErr = false; tone(3, 1000, 100); return; } else { invalidResponse = true; //do this if something else arrives (retries polling) } } } } } while (invalidResponse == true); }
Last edited by Dannyx; 10-22-2020, 06:41 AM.Leave a comment:
-
Re: Remote pump control ideas.
power can be reduced to nothing,
you can shutdown the i/o in blocks so only the core runs, and even change the clockspeed on the fly.
you can also stall the core and have it start on an interupt from a pin or from a built-in RTC so you can have it do something every second, every hour or every day - whatever you can think of - the RTC even has it's own power pin so you could hook it to an 18650 circuit or something.Leave a comment:
-
Re: Remote pump control ideas.
No idea how much power the board uses (when powered with 12v that is), since I haven't taken it out of the packaging yetThe GPON will also draw some power of its own.
I'm still working on the code on my Arduino, since I wasn't happy with how it turned out the first time and I want to do a better job at both writing it AND implementing the whole idea. This time I WILL actually share it, since I feel more confident I won't get roasted as hard
I started getting the hang of it better and now understand functions, since that's always been confusing AF to me as to how to pass info back and forth between the main loop and the function and also "returns" and stuff like that. It all becomes SO easy when you understand the program runs line by line, even if extremely fast which makes it look like more things happen at once - they don't - they just feel that way, like persistence of vision...again, this is all in layman termsLeave a comment:
-
Re: Remote pump control ideas.
I did not take the plunge into STM32 family, all these ARM MCU's have 1,200+ page datasheets which seem ridiculous for one person to learn and be proficient at. For now going with ATSAMD51 boards for higher performance or ESP32.Leave a comment:
-
Re: Remote pump control ideas.
How is the power consumption of the board?
I'm not sure what is going on at the tank station but can't see solar power working with Ethernet, it uses a lot of current. Then just go POE if there is a cable run?
I did not take the plunge into STM32 family, all these ARM MCU's have 1,200+ page datasheets which seem ridiculous for one person to learn and be proficient at. For now going with ATSAMD51 boards for higher performance or ESP32.Leave a comment:
Related Topics
Collapse
-
by tmhobadcapI have this receiver for at least 10 years. Usually, we just use the remote for turning on/off and adjusting the volume. Recently, the remote control started not able to turn the receiver on. Later, the volume also could not be adjusted by the remote control.
At first, I thought that it was the usual problem which can be fixed by cleaning the contacts on the switches and the pcb. I opened the remote and clean it with alcohol. The remote did work again after that. But after one day, it did not work again. I opened it again and clean with alcohol and contact cleaner. Again it worked... -
This specification for the HP Mobile Thin Client mt44 Mobile Thin Client 3JG86EA Mobile thin client can be useful for upgrading or repairing a laptop that is not working. As a community we are working through our specifications to add valuable data like the mt44 Mobile Thin Client 3JG86EA boardview and mt44 Mobile Thin Client 3JG86EA schematic. Our users have donated over 1 million documents which are being added to the site. This page will be updated soon with additional information. Alternatively you can request additional help from our users directly on the relevant badcaps forum. Please note...09-06-2024, 06:50 AM
-
by piipoHi, I have an old Privileg brand 5.1 speakers. I have lost the remote control. I have an universal Harmony remote but there is no Privileg brand in it's software to add. Does anybody have an idea what alternative brand for a remote can I try instead? I'm attaching an image of what the speakers looks like. The image shows 2 main speakers, they are 5 + 1 in total. Thank you very much1 Photo
-
Channel: Troubleshooting Audio Equipment
09-18-2024, 01:55 AM -
-
This specification for the HP mt44 Mobile Thin Client Mobile thin client can be useful for upgrading or repairing a laptop that is not working. As a community we are working through our specifications to add valuable data like the mt44 Mobile Thin Client boardview and mt44 Mobile Thin Client schematic. Our users have donated over 1 million documents which are being added to the site. This page will be updated soon with additional information. Alternatively you can request additional help from our users directly on the relevant badcaps forum. Please note that we offer no warranties that any specification,...09-06-2024, 06:50 AM
-
This specification for the HP mt44 Mobile Thin Client Mobile thin client can be useful for upgrading or repairing a laptop that is not working. As a community we are working through our specifications to add valuable data like the mt44 Mobile Thin Client boardview and mt44 Mobile Thin Client schematic. Our users have donated over 1 million documents which are being added to the site. This page will be updated soon with additional information. Alternatively you can request additional help from our users directly on the relevant badcaps forum. Please note that we offer no warranties that any specification,...09-06-2024, 06:50 AM
- Loading...
- No more items.
Leave a comment: