Arduino for relay controls

More
12 Jan 2015 12:57 #54908 by justinj
Just wondering if it's possible (or maybe someone is already running it) to use an Arduino over it's USB>UART port to control simple things like the pump/fans/vacuums/blowers/anything that can be run from a relay really, that aren't time sensitive like the steppers so they can be turned on and off from the interface? Arduino's are so cheap now, and to be able to operate several relays from the interface for the low cost of an Arduino would be great as I only have the 1 parallel port on my PC.

Please Log in or Create an account to join the conversation.

More
12 Jan 2015 18:04 #54922 by ArcEye
Replied by ArcEye on topic Arduino for relay controls
Hi

Arduinos certainly are cheap nowadays, especially the Chinese knock offs, haven't looked at them for a bit.

However BOBs are too, £9 for a board and DB25 cable and another £3.99 for a netMos 9865 PCI parport card.

If it is purely on cost, there is nothing in it really and the extra parport is simple.

If you are interested in exploring serial comms with the arduino etc. go for it.

There is an example of a user space component and corresponding arduino script to use the arduino via USB/serial as a pendant here, which would get you started regards the
serial interface required etc
www.linuxcnc.org/index.php/english/forum...pendant-for-linuxcnc

regards
The following user(s) said Thank You: justinj

Please Log in or Create an account to join the conversation.

More
12 Jan 2015 18:10 #54923 by justinj
Replied by justinj on topic Arduino for relay controls

Hi

Arduinos certainly are cheap nowadays, especially the Chinese knock offs, haven't looked at them for a bit.

However BOBs are too, £9 for a board and DB25 cable and another £3.99 for a netMos 9865 PCI parport card.

If it is purely on cost, there is nothing in it really and the extra parport is simple.

If you are interested in exploring serial comms with the arduino etc. go for it.

There is an example of a user space component and corresponding arduino script to use the arduino via USB/serial as a pendant here, which would get you started regards the
serial interface required etc
www.linuxcnc.org/index.php/english/forum...pendant-for-linuxcnc

regards

I didn't realise the PCI cards were so cheap! (Although when I search that model I'm getting serial PCI adaptors not Parallel?). I guess I'll look at that then instead! Any recommendations on some BOBs that have relays built into them already just to simplify the whole process?

Please Log in or Create an account to join the conversation.

More
12 Jan 2015 18:42 #54925 by ArcEye
Replied by ArcEye on topic Arduino for relay controls
As you are in the Antipodes, searched your version of ebay

This one I chose because you can zoom on the chip and clearly read 9865
There are others which appear to be the same for less than $5
www.ebay.com.au/itm/DB25-Parallel-Printe...&hash=item417f7b7576

BOB, even this one has one relay on it, plus a DB25 cable
www.ebay.com.au/itm/Breakout-Board-Inter...&hash=item51bca216c6

If you need more relays, there are things like this in the arduino world that work off 5v and are dirt cheap,
www.ebay.com.au/itm/4-Channel-5V-Relay-M...&hash=item51c5a8a82c

If you can only supply 3.3v, there are ones with a 5v OB supply that can be activated by a lower voltage signal
www.ebay.com.au/itm/3-3V-5V-Opto-Isolate...&hash=item20f39a8eaf

Of course they all come from China or HK, but at least it is a lot closer to you

regards
The following user(s) said Thank You: justinj

Please Log in or Create an account to join the conversation.

More
12 Jan 2015 21:04 #54933 by andypugh
Replied by andypugh on topic Arduino for relay controls

Just wondering if it's possible (or maybe someone is already running it) to use an Arduino over it's USB>UART port


Yes, there is a HAL component specifically for this, but it isn't part of the standard installation:
emergent.unpythonic.net/01198594294
The following user(s) said Thank You: justinj

Please Log in or Create an account to join the conversation.

More
13 Jan 2015 05:06 #54946 by justinj
Replied by justinj on topic Arduino for relay controls
Thanks for the relevant links :)
As I'm new to the CNC world I think I'll just go for the PCI>Parallel port option as it ties in with EMC directly without additional HAL components.
I'm assuming that as you've mentioned the 9865 that it is compatible with LinuxCNC? How does one select the port start address with the PCI cards (The onboard one has BIOS options for setting)?

Please Log in or Create an account to join the conversation.

More
13 Jan 2015 15:19 #54963 by ArcEye
Replied by ArcEye on topic Arduino for relay controls
See my FAQ as a starter

www.linuxcnc.org/index.php/english/forum...-parallel-port-cards

The netMos 9865 chip works with Linuxcnc.

regards
The following user(s) said Thank You: justinj

Please Log in or Create an account to join the conversation.

More
13 Jan 2015 15:25 #54964 by justinj
Replied by justinj on topic Arduino for relay controls

See my FAQ as a starter

www.linuxcnc.org/index.php/english/forum...-parallel-port-cards

The netMos 9865 chip works with Linuxcnc.

regards

Spot on what I needed!!! Thanks :)

Please Log in or Create an account to join the conversation.

More
13 Feb 2015 01:38 - 13 Feb 2015 01:39 #55932 by TroyO
Replied by TroyO on topic Arduino for relay controls
Heh, on topic if not on-subject, I am using an Arduino Nano to control 4 relays as my chargepump/watchdog circuit.

If I stop getting a train of pulses from the PPort over 2k, it shuts down mains power to Spindle/Steppers/Coolant/Etc.

I know it's not exactly what is being discussed, but someone may find it interesting...I also am interested in the project using the arduino to gain some I/O since I already have one set up on my system anyway... I smell an opportunity to add more features, LOL. (Not that I actually can think of a USE for them yet. ;-) )

Attached is a pic of the wiring.



Anyway, code below if anyone is interested.
//*Frequency*counter*sketch,*for*measuring*frequencies*low*enough*to*execute*an*interrupt*for*each*cycle
//*Connect*the*frequency*source*to*the*INT0*pin*(digital*pin*2*on*an*Arduino*Uno)

volatile*unsigned long firstPulseTime;
volatile*unsigned long lastPulseTime;
volatile*unsigned long numPulses;
int ledPin = 13;
int relay1Pin = 3;
int relay2Pin = 4;
int relay3Pin = 5;
int relay4Pin = 6;
void isr()
{
**unsigned long now = micros();
**if (numPulses == 1)
**{
****firstPulseTime*=*now;
**}
**else
**{
****lastPulseTime*=*now;
**}
**++numPulses;
}

void setup()
{
Serial.begin(19200);    // this is here so that we can print the result
digitalWrite (relay1Pin, HIGH);
digitalWrite (relay2Pin, HIGH);
digitalWrite (relay3Pin, HIGH);
digitalWrite (relay4Pin, HIGH);
pinMode(2,INPUT_PULLUP); 
pinMode(ledPin, OUTPUT);
pinMode(relay1Pin, OUTPUT);
pinMode(relay2Pin, OUTPUT);  
pinMode(relay3Pin, OUTPUT);  
pinMode(relay4Pin, OUTPUT);  
**digitalWrite (ledPin, HIGH);
**Serial.println("Delaying 60 Seconds to allow PC Boot");
**delay (10000);
****digitalWrite (ledPin, LOW);
**Serial.println("50 Seconds Remaining");
**delay (10000);
****digitalWrite (ledPin, HIGH);
**Serial.println("40 Seconds Remaining");
**delay (10000);
****digitalWrite (ledPin, LOW);
**Serial.println("30 Seconds Remaining");
**delay (10000);
****digitalWrite (ledPin, HIGH);
**Serial.println("20 Seconds Remaining");
**delay (10000);
**digitalWrite (ledPin, LOW);
**Serial.println("10 Seconds Remaining");
**delay (10000);
****digitalWrite (ledPin, HIGH);
**Serial.println("Charge Pump Started");
}

//*Measure*the*frequency*over*the*specified*sample*time*in*milliseconds,*returning*the*frequency*in*Hz
float readFrequency(unsigned int sampleTime)

{*numPulses*=*0;**********************// prime the system to start a new reading
**attachInterrupt(0, isr, RISING);    // enable the interrupt
**delay(sampleTime);
**detachInterrupt(0);
**return (numPulses < 3) ? 0 : (1000000.0 * (float)(numPulses - 2))/(float)(lastPulseTime - firstPulseTime);
}


void loop()
{

**
**float freq = readFrequency(100);
****if ( freq > 2000)
{
**digitalWrite (ledPin, HIGH);
**digitalWrite (relay1Pin, LOW);
**digitalWrite (relay2Pin, LOW);
**digitalWrite (relay3Pin, LOW);
**digitalWrite (relay4Pin, LOW);
**
**Serial.print("ChargePump Active. Current Frequency: ");
**Serial.println(freq);
}
else
{
**digitalWrite (ledPin, LOW);
**digitalWrite (relay1Pin, HIGH);
**digitalWrite (relay2Pin, HIGH);
**digitalWrite (relay3Pin, HIGH);
**digitalWrite (relay4Pin, HIGH);
**Serial.print("ChargePump Inactive. Current Frequency: ");
**Serial.println(freq);
}

**delay(100);
}
Attachments:
Last edit: 13 Feb 2015 01:39 by TroyO.

Please Log in or Create an account to join the conversation.

Time to create page: 0.103 seconds
Powered by Kunena Forum