Biopowered - vegetable oil and biodiesel forum

Biodiesel => Biodiesel equipment => Topic started by: Tony on June 02, 2013, 02:41:39 PM

Title: Finally got around to playing with the Raspberry Pi
Post by: Tony on June 02, 2013, 02:41:39 PM
Nice little thing!

http://www.biopowered.co.uk:31415/

 8)
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: greasemonkey on June 02, 2013, 02:51:33 PM
Hi Pi.
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: Tony on June 02, 2013, 03:25:50 PM
Ultimately it would be nice in the shed, reporting process temps and running a webcam to keep an eye on things.
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: Julian on June 02, 2013, 04:35:34 PM
Ultimately it would be nice in the shed, reporting process temps and running a webcam to keep an eye on things.

I could do with one of those pointed at the bottom of my Mono!

But it sounds like a great project to detail on the wiki.  How easy is the interfacing between sensors and the PC.
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: therecklessengineer on June 09, 2013, 08:40:58 PM
I've got mine running as a Ninjablock: https://api.ninja.is/signin?redirect=home (https://api.ninja.is/signin?redirect=home)

Currently, it's just running RGB LED light strips. Expanding to do temperatures/pressures etc isn't that hard.
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: Tony on December 14, 2013, 10:41:02 PM
Rejuvinating an old thread.

The missus won some 600 Mbps ZyXEL power line adapters - so I thought I'd see how well they work through the SWA cable buried under the garden to the shed.  Surprisingly well as it turns out.

http://pi.cooldark.com/

My only concern is moisture and condensation - I think it would be good to keep the pi in a box with some desiccant.
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: therecklessengineer on December 15, 2013, 07:30:50 AM
Have a look here:

http://ninjablocks.com/ (http://ninjablocks.com/)

I've set up my pi as a ninja block. With the aid of an Arduino acting as an A/D converter I can grab and display data from the outside world.

There's a widget on this page showing the current temperature in my barn. www.lmbl.co.uk (http://www.lmbl.co.uk)
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: Tony on December 15, 2013, 11:30:03 AM
Nice :)

The missus has ordered me these as xmas pressies:

http://www.ebay.co.uk/itm/USB-8-RELAY-CARD-BOARD-MODULE-OPTOISOLATION-/260928415996

(http://i.ebayimg.com/t/USB-8-RELAY-CARD-BOARD-MODULE-OPTOISOLATION-/00/s/MjM3WDMwMA==/$(KGrHqN,!lME65,rVMh6BPBES!uctg~~60_35.JPG)

http://www.ebay.co.uk/itm/TEMPer1K4-PC-Sensor-USB-Thermocouple-K-Type-Thermometer-Temperature-Meter-/281224585770

(http://i.ebayimg.com/t/TEMPer1K4-PC-Sensor-USB-Thermocouple-K-Type-Thermometer-Temperature-Meter-/00/s/MTAwMFgxMDAw/z/rg4AAMXQlgtSpuZw/$_12.JPG)

Got plenty of SSRs (with snubbers) so will have a crack at immersion and pump motor control with it.  Quite like the idea of dialling in a temperature from the comfort of my living room :)

To start with it'll just interface with the existing system, I'll just set the manual themostat to max and let the Pi have free reign.  It will still have the liquid level deadlock on the immersion that way too.
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: therecklessengineer on December 15, 2013, 12:09:52 PM
Yes, I saw those too. Look pretty cool. I like that it's all done on the local network. Where Ninjablocks fails for me is that it must connect via the ninja servers on the outside internet. If you loose your net connection then it falls over.
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: Tony on December 15, 2013, 02:27:24 PM
Did you see these too?

http://www.ebay.co.uk/itm/USB-to-SPI-I2C-ADC-GPIO-Converter-Analyser-PC-or-Raspberry-Pi-/291022262950
http://www.ebay.co.uk/itm/12-I-O-USB-Controller-PIC18F14K50-USB-GPIO12-/321269400546

The latter is quite interesting, looks like it has a bootloader so you can cross-compile you own app for it.

I'd quite like some form of opto-isolated GPIO inputs to the Pi for switch based sensors (level, push buttons) but not sure how to implement such a thing.  I guess it would have to raise an interrupt at the Pi end which then scans input GPIO.  I've not really looked to see if the Pi has an interrupt input but it must do on its interface somewhere.

I like the idea of keeping it out on a USB peripheral but then how would an interrupt work?
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: therecklessengineer on December 15, 2013, 05:18:53 PM
They look pretty cool.

I like the Arduino platform as the libraries available are enormous and the development environment is very easy to use.

You'd have to poll the inputs for a state change I'd have thought.

My Arduino-PI interface just pumps JSON encoded data back and forth over a serial interface.
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: julianf on December 15, 2013, 09:36:51 PM
If i get Tony to wire my reactor up to the net, anyone want to make my bio for me?
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: Tony on December 16, 2013, 11:40:18 PM
I've got the Pi serving up web pages generated by a Python script on that address now.  Not yet figured out how to get a handle on the request URL yet though, hence the extra debug.

Plan is to write Python modules to control everything, IE have an object such that Processor.MainPump(1) will start the pump and Processor.GetTemp() will return the oil temperature so it can be integrated into web controls.
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: therecklessengineer on December 17, 2013, 06:39:45 AM
You might like to look at this:

http://www.fritz-hut.com/2012/09/04/arduinopiv1.0-includes-api/ (http://www.fritz-hut.com/2012/09/04/arduinopiv1.0-includes-api/)
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: Bill on December 17, 2013, 07:39:04 AM
I've semi automated my processor using a Velleman VM110 I/O board and VM132 temperature sensor. All controlled by wifi from an old tablet pc I carry round when its running. Had it running now for over a year. Programmed in VisualBasic.
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: Tony on December 17, 2013, 07:45:32 AM
I've semi automated my processor using a Velleman VM110 I/O board and VM132 temperature sensor. All controlled by wifi from an old tablet pc I carry round when its running. Had it running now for over a year. Programmed in VisualBasic.

Hi Bill

Do you implement a control loop for temp vs heater on or is that controlled manually?
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: Tony on December 17, 2013, 07:49:45 AM
You might like to look at this:

http://www.fritz-hut.com/2012/09/04/arduinopiv1.0-includes-api/ (http://www.fritz-hut.com/2012/09/04/arduinopiv1.0-includes-api/)

He's got an interesting approach exposing the API on the web.  I did ponder doing everything in PHP as I'm used to PHP for web apps.  But what I'm not so sure about is having PHP run full-time as a control loop for a heater, for example - whereas python can quite happily do this.

My natural tendency is to write everything in C or C++, but that's too much like being at work ;)
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: therecklessengineer on December 17, 2013, 12:20:03 PM
You might like to look at this:

http://www.fritz-hut.com/2012/09/04/arduinopiv1.0-includes-api/ (http://www.fritz-hut.com/2012/09/04/arduinopiv1.0-includes-api/)

He's got an interesting approach exposing the API on the web.  I did ponder doing everything in PHP as I'm used to PHP for web apps.  But what I'm not so sure about is having PHP run full-time as a control loop for a heater, for example - whereas python can quite happily do this.

My natural tendency is to write everything in C or C++, but that's too much like being at work ;)

Yes, I feel the same way!

You could have the PID loop running on the Arduino (libraries available for that!) and just pass the set point to it from the PI. That would be my approach if I ever get around to it.
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: Tony on December 17, 2013, 12:31:35 PM
You might like to look at this:

http://www.fritz-hut.com/2012/09/04/arduinopiv1.0-includes-api/ (http://www.fritz-hut.com/2012/09/04/arduinopiv1.0-includes-api/)

He's got an interesting approach exposing the API on the web.  I did ponder doing everything in PHP as I'm used to PHP for web apps.  But what I'm not so sure about is having PHP run full-time as a control loop for a heater, for example - whereas python can quite happily do this.

My natural tendency is to write everything in C or C++, but that's too much like being at work ;)

Yes, I feel the same way!

You could have the PID loop running on the Arduino (libraries available for that!) and just pass the set point to it from the PI. That would be my approach if I ever get around to it.

An embedded micro would indeed be ideal for that kind of thing.

Wouldn't take much of a control loop, really PIDs are overkill for running a resistive heating element .

What I like about python is that tweeking it is very very easy.  I know from work that python scripts can run for extended times (we've has some simulators running weeks) and there are python scrypt mining proxies (EG stratum) that I've used for extended times as well.  So I'm happy enough to do it that way on the Pi, though perhaps with a crontab based watchdog just in case.

So the idea of a python web interface with AJAX style JSON comms to an always-running control script appeals quite a lot.

It could log all actions, something like

12:45 [control] user set temp to 65C
12:45 [action] heater 1 ON
14:11 [control] temp reached target of 65C
14:11 [action] heater 1 OFF
14:15 [control] temp 63C below hysteresis threshold
14:15 [action] heater 1 ON
14:17 [control] temp reached target of 63C
14:17 [action] heater 1 OFF
15:01 [control] user enabled circulation pump 1
15:01 [action] pump 1 ON

What could possibly go wrong? :)
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: Bill on December 17, 2013, 03:26:39 PM
Temperature control is within the VB program, just a simple on/off between temperature limits 1.5 deg either side of the target temperature. More than adequate for my needs, no need for a PID routine.
Before I started the remote control stuff I had a PID controller which is now set to some degrees above the processing target temperatures so it doesn't interfere. I can still go back to manual running if the automation fails.
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: therecklessengineer on December 17, 2013, 04:27:02 PM
It could log all actions, something like

It could also ping you an email when it's up to temperature.  ;D

I don't like the burst fire method of PID regulation. It upsets Lizzie with the load coming on and off. My hypothetical automation system would check the load before allowing heat.

You'd be interested in the marine automation systems. Far too complex to go into here though. Perhaps at the next BBB.

Your system sounds cool Bill. If I ever get mine running, I'd do the same and use an old tablet as an interface. Perhaps even with another screen mounted somewhere so I can monitor while watching the box.

It did occur to me that a car central locking motor would be ideal for actuating a ball valve...
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: Tony on December 17, 2013, 04:37:06 PM
It could log all actions, something like

It could also ping you an email when it's up to temperature.  ;D

I don't like the burst fire method of PID regulation. It upsets Lizzie with the load coming on and off. My hypothetical automation system would check the load before allowing heat.

You'd be interested in the marine automation systems. Far too complex to go into here though. Perhaps at the next BBB.

Your system sounds cool Bill. If I ever get mine running, I'd do the same and use an old tablet as an interface. Perhaps even with another screen mounted somewhere so I can monitor while watching the box.

It did occur to me that a car central locking motor would be ideal for actuating a ball valve...

I've been contemplating how to do this too.  Wiper motors are probably pretty good for this kind of thing too, though perhaps a bit too powerful (find one on a mini?)  Or a stepper motor on a gate valve?

Then you're into the land of vacuum sensing the venturi port and checking pump head pressure to make sure the valves operated correctly...  All doable :)
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: julianf on December 17, 2013, 04:50:52 PM
Central heating valves are commonly electrically operated.  I dont know what the bore is like on them though (full bore?).

Theyre not that cheap, but way simpler than hooking up motors to lever valves.



Are you working in Python for this?  I dont know much about the pi, but im aware other languages are possible also.


Title: Re: Finally got around to playing with the Raspberry Pi
Post by: Tony on December 17, 2013, 05:07:16 PM
Central heating valves are commonly electrically operated.  I dont know what the bore is like on them though (full bore?).

Theyre not that cheap, but way simpler than hooking up motors to lever valves.

Are you working in Python for this?  I dont know much about the pi, but im aware other languages are possible also.

CH valves aren't full bore and I think they might have an o-ring seal in the changeover part (I'll take a look tonight, I think I kept the one that failed on my boiler circuit).

Yes Python just because I fancy doing it in Python.  Ruby, PHP, C... it's all possible.  I'm a C coder by trade but Python makes for much quicker bringup and no need for cross compiling (native C compiling on the Pi is a little tedious).
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: Bill on December 17, 2013, 07:46:41 PM
I used a 3/8"BSP 12v solenoid valve on the drain, it has viton seals. Works OK but flow rate is low, not a problem in a 50 lt processor. The lower flow rate on a drain valve probably makes it a little more controllable. Bigger valves are available, they start to get expensive but they are easy to open and close.
Got it from solenoidvalvesuk.com
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: Tony on December 17, 2013, 07:53:29 PM
Was it expensive?  For a drain valve slow is good.  Do you have an opto-sensor and light to watch for the phase change?

I've got some washing machine valves but I think they would melt.  And 1" ones for the pipework probably get very expensive.
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: Bill on December 18, 2013, 07:49:10 AM
The valve was about £65. I use honeywell optical level sensor (very expensive but very good at what they do) to monitor liquid level. I don't drain to completion (the phase change) just to a preset level or to a preset level then an additional time increment, depends on process stage. Detection of liquid level is easier than trying to detect a phase change. Batch sizes have to be pretty constant batch to batch.
To me it doesn't matter if there is a bit of glyc left behind or wash water, it won't screw up the next process step. Hence no need to detect a phase change ie glyc to bio or wash water to bio. I have a manual override button for the drain valve if needed to drain some more between stages.
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: therecklessengineer on December 18, 2013, 12:30:06 PM
Perhaps we should have a section of the forum for DIY industrial automation projects?  8)
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: Julian on December 19, 2013, 10:44:04 AM
A windscreen wiper motor should have enough torque to drive a standard ball valve.

I assume they can be reversed, if so you just need a couple of limit switches and a bracket.
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: Tony on December 19, 2013, 11:38:35 AM
Perhaps we should have a section of the forum for DIY industrial automation projects?  8)

Great idea.  Done - lets see how it goes and whether it gets any use (otherwise we'll just merge it back).
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: therecklessengineer on December 19, 2013, 04:34:19 PM
Of course this section shouldn't be just for whizzy tablet web based projects in PHP using AJAX, Python, or building your own custom OS. Just wiring up a PID controller or having a remote temperature sensor should fall into this category.
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: Julian on December 19, 2013, 04:44:32 PM
Would  ... Controls, instrumentation and automation be more descriptive then?
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: Tony on December 19, 2013, 05:14:16 PM
Would  ... Controls, instrumentation and automation be more descriptive then?

Definitely - doooo it!
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: Julian on December 19, 2013, 05:26:52 PM
That's easy for you to say!
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: Bill on December 19, 2013, 07:04:00 PM
I would agree that automation begins with such basic things as PID controllers.
I hadn't realised the potential for automation until I had first played around with timer delay relays for parts of pumped water washing, etc. It demonstrated that a process with little batch to batch variability (ie an almost boring, repetitive task) was a good target for automation.
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: andrzej.b on April 08, 2014, 08:39:41 PM
Hey guys,

How hard would it be; has any of you tried to use raspberry pi to automatically control switching between WVO and diesel on a 2 tank system?
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: Tony on April 09, 2014, 06:46:40 AM
Welcome to the forum. The pi has some gpio pins, so most definitely possible but you would need some buffer electronics between it and the car, ie relay drive circuit.
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: therecklessengineer on April 09, 2014, 01:22:07 PM
The RPi is way overkill for something like that.

You want a basic microcontroller. Arduino, MSP430, PIC etc etc.
Title: Re: Finally got around to playing with the Raspberry Pi
Post by: andrzej.b on April 10, 2014, 02:28:54 PM
Welcome to the forum. The pi has some gpio pins, so most definitely possible but you would need some buffer electronics between it and the car, ie relay drive circuit.

Thanks. Yup, would definitely use relays. I'm just more of a mechanic/electrician and don't know anything about programing.  :)

The RPi is way overkill for something like that.

You want a basic microcontroller. Arduino, MSP430, PIC etc etc.

I already have a pi and maybe I would use it for playing movies or music in addition.  What I would like it to do is:

Start the car on diesel
Once the oil warms up, for the pi to switch to the oil
Once I take the key out for the pi to switch back to diesel and to keep the car  until the fuel line flushes
I would also like it to keep the oil warm when the car is off with some electric heaters powered from outlet. Basically I would park it and plug it into an outlet for the night.
I would also like it to keep the oil war even when unplugged from an outlet using the car's battery but to monitor battery voltage so that not to discharge it below a certain level.
Hell, maybe even start the car at a certain preset time to warm it up in winter and cool down in summer.  ;D