Brum Reaper's Harvest
Random projects, musings, howtos, tips and photographs from the Brum Reaper.
Friday 16 March 2012
Now with added wireless
Unlike the jeenodes, arduinos don't usually come with an RFM12b wireless transmitter. But jeelabs sell a handy module.
The USB host port on the Mega ADK communicates using the SPI bus. So does the wireless module, but fortunately the bus can be shared. The three main bus signals (MOSI, MISO, SCK) can be connected to different clients, only the Slave Select (SS) needs to be separate. On top of that, the wireless module requires an interrupt line.
On the Mega board, I used pins 52, 51, 50 for SCK, SDI (MOSI) and SDO (MISO); pin 48 for SS (just because it was next to 50 and 52), and 19 for IRQ - plus of course 5V and GND.
I had to modify the jeelabs RF12 library a bit. The library expects to use either the default interrupt 0 (on pin 2), or a pin-change based interrupt on any other pin. On the Mega 2560 and ADK, four additional interrupt lines can be used. I didn't want to use IRQ 0 in case it is required for the USB host, so I used one of the additional interrupts - IRQ 4 on pin 19. To do that, I had to change the call to attach() and detach() to take an IRQ number other than 0. Pin 48 is on Port L.
Throughout RF12.cpp, I've renamed RFM_IRQ into RFM_IRQ_PIN, and then
...
This is successfully running the RF12demo and the pingPong demo. I still have to test how this works when both USB and wireless are active - once I can send commands from the tablet to a node connected via wireless, I've got the backbone working.
The USB host port on the Mega ADK communicates using the SPI bus. So does the wireless module, but fortunately the bus can be shared. The three main bus signals (MOSI, MISO, SCK) can be connected to different clients, only the Slave Select (SS) needs to be separate. On top of that, the wireless module requires an interrupt line.
On the Mega board, I used pins 52, 51, 50 for SCK, SDI (MOSI) and SDO (MISO); pin 48 for SS (just because it was next to 50 and 52), and 19 for IRQ - plus of course 5V and GND.
I had to modify the jeelabs RF12 library a bit. The library expects to use either the default interrupt 0 (on pin 2), or a pin-change based interrupt on any other pin. On the Mega 2560 and ADK, four additional interrupt lines can be used. I didn't want to use IRQ 0 in case it is required for the USB host, so I used one of the additional interrupts - IRQ 4 on pin 19. To do that, I had to change the call to attach() and detach() to take an IRQ number other than 0. Pin 48 is on Port L.
Throughout RF12.cpp, I've renamed RFM_IRQ into RFM_IRQ_PIN, and then
#if defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__) #define RFM_IRQ 4 #define RFM_IRQ_PIN 19 // was 2 #define SS_DDR DDRL #define SS_PORT PORTL #define SS_BIT 1 #define SPI_SS 53 // PB0, pin 19 #define SPI_MOSI 51 // PB2, pin 21 #define SPI_MISO 50 // PB3, pin 22 #define SPI_SCK 52 // PB1, pin 20
...
#else
if ((nodeid & NODE_ID) != 0)
attachInterrupt(RFM_IRQ, rf12_interrupt, LOW);
else
detachInterrupt(RFM_IRQ);
#endif
This is successfully running the RF12demo and the pingPong demo. I still have to test how this works when both USB and wireless are active - once I can send commands from the tablet to a node connected via wireless, I've got the backbone working.
Thursday 15 March 2012
Bridged !
Finally, the tablet and the (new) kitchen node are talking. I say new kitchen node, as I've had to switch to a Arduino Mega ADK. It's not connected through ADK (we've already established that the tablet doesn't support that), but through something called Microbridge. Microbridge is a client to Android's ADB debugging interface - it can do a subset of the things the normal ADB client can do, including tunnelling TCP streams.
It didn't all go smoothly, both the Microbridge library and the example sketches need modifications before they work. I'll describe the changes that need to be done, and will link a zip of the modified files.
Update: I've put a tar file of the modified microbridge library here. There's still something wrong with the LogCat example: you need to re-plug USB to get the tablet into USB debug mode, but that somehow immediately get cancelled again. If you first run the shell example and then the logcat example, it works.
It didn't all go smoothly, both the Microbridge library and the example sketches need modifications before they work. I'll describe the changes that need to be done, and will link a zip of the modified files.
- wiring.h The cpp files include wiring.h. This has been superseded by Android.h
- Mega ADK hardware description: max3421e.h has a section of definitions protected by #ifdef ADK_REF_BOARD. The contents of this section is correct for the board, but is not compiled. I don't know what the correct symbol for the board is, I just got rid of the #ifdef and corresponding #endif.
- The board initialization in max3421e.cpp is not working correctly, it should look like this (change in the last line, see also this post):
SPI.begin(); pinMode(PIN_MAX_INT, INPUT); pinMode(PIN_MAX_GPX, INPUT); pinMode(PIN_MAX_SS, OUTPUT); DDRJ |= _BV (PJ2);
- The examples use serial -> print, it should be serial -> write. Otherwise you get just random numbers.
- The WriteFile example doesn't work for me, as the location used for creating the file (/sdcard/hello) is mounted write-only. Since this example doesn't read back the result, you won't see an error message.
- The LogCat demo appears to be working fine (with the print/write change). You may have to unplug/replug your connection to the tablet to make sure it's in debug mode.
- The Shell example has two problems. First, it checks the status of the connection before writing, but does not allow for ADB_RECEIVING. So it will incorrectly complain about the shell not being open.
- The other Shell problem is that it does not send a carriage-return symbol at the end of a transmission. So you can type 'ls' into the serial monitor, but that never gets executed.
Update: I've put a tar file of the modified microbridge library here. There's still something wrong with the LogCat example: you need to re-plug USB to get the tablet into USB debug mode, but that somehow immediately get cancelled again. If you first run the shell example and then the logcat example, it works.
Monday 12 March 2012
Boiler Control
The laundry node won't just be a passive note-taker, it will also control the boiler.
Our boiler has a basic programmable timer built in, with a limited number of timing slots (which are cumbersome to change). That should be much easier with a tablet based gui, with schedules uploaded to the jeenode. The boiler provides contacts that are in series with the timer switch (by default bridged), meant for an external thermostat. It's easy to just add a relay into the circuit, turn the built-in timer to 'always on', and have the node control the on-off times (just in case, I will add a manual switch parallel to the arduino-controlled relay, so that we can always fall back to the build-in control).
We can do more than just provide a better control of the schedules: optimized start up. Instead of pre-programming the startup time of the boiler in the morning, we can sense the external temperature over night, and then delay starting the heating to the last possible moment. The longer the house remains cool over night, the less heat we lose. There' a possible downside to this though: it could increase our consumption. After cold nights, we sometimes find it too cold for our taste in the kitchen - we've under-heated. With optimal startup, the kitchen should always be reasonably warm when we need it, but that might mean coming on earlier than we'd program it to.
Ideally, I'd want to control the temperature setting, but that would require a more invasive change to the boiler. It has a potentiometer for setting the heating circuit temperature. I'd have to either somehow connect a motor to turn the potentiometer, or replace the potentiometer with something like a switched resistor ladder. Varying the temperature throughout the day should improve the efficiency of the boiler, but that's something that may have to wait.
Update I've realized that I can find out something else: the flow through the heating circuit depends only on the state of the thermostats in the house. If most of them are closed, the pump will be able to pump less water. If very little water flows (only through the bathroom), I can consider turning off the heating (at least for a while).
Our boiler has a basic programmable timer built in, with a limited number of timing slots (which are cumbersome to change). That should be much easier with a tablet based gui, with schedules uploaded to the jeenode. The boiler provides contacts that are in series with the timer switch (by default bridged), meant for an external thermostat. It's easy to just add a relay into the circuit, turn the built-in timer to 'always on', and have the node control the on-off times (just in case, I will add a manual switch parallel to the arduino-controlled relay, so that we can always fall back to the build-in control).
We can do more than just provide a better control of the schedules: optimized start up. Instead of pre-programming the startup time of the boiler in the morning, we can sense the external temperature over night, and then delay starting the heating to the last possible moment. The longer the house remains cool over night, the less heat we lose. There' a possible downside to this though: it could increase our consumption. After cold nights, we sometimes find it too cold for our taste in the kitchen - we've under-heated. With optimal startup, the kitchen should always be reasonably warm when we need it, but that might mean coming on earlier than we'd program it to.
Ideally, I'd want to control the temperature setting, but that would require a more invasive change to the boiler. It has a potentiometer for setting the heating circuit temperature. I'd have to either somehow connect a motor to turn the potentiometer, or replace the potentiometer with something like a switched resistor ladder. Varying the temperature throughout the day should improve the efficiency of the boiler, but that's something that may have to wait.
Update I've realized that I can find out something else: the flow through the heating circuit depends only on the state of the thermostats in the house. If most of them are closed, the pump will be able to pump less water. If very little water flows (only through the bathroom), I can consider turning off the heating (at least for a while).
Sunday 11 March 2012
Virtual Gasmeter
I mentioned yesterday that I've ordered two water flow meters. Despite measuring water flow, their main use will be to help me attribute our gas consumption.
First, the water flow meters will be cut into both the heating circuit and the domestic hot water output. Pairs of temperature sensors will go onto the incoming and outgoing pipes of both circuits. By measuring flow and temperature difference, I can work out exactly how much power the boiler is actually putting out. At the same time, I will measure the overall gas consumption at the house gas meter (luckily mine has an impulse at the lowest gear).
Most of the time (during winter) the gas will be used to heat the house - with brief periods for hot water, and for cooking in the evening. I know when we're using gas for hot water, because the flow in the heating circuit stops, and starts in the hot water circuit. But what about cooking?
That took some thinking (I considered a camera above the hob, or sensors on the cooker controls), but then I realized that I can learn a model of the efficiency of the boiler, probably dependent on outside temperature, maybe also return flow temperature. That model can be calibrated with data from times when I know I am not cooking (i.e. most of the day). Knowing the power output at any time, I can compare the gas consumption predicted by the model with that measured at the meter point - any additional gas used will have gone into cooking.
That way I can use inexpensive water meters to create virtual gas meters. And know exactly how much of our gas consumption went onto heating, hot water, and cooking.
(Virtual sensors and data driven modelling is my research area).
First, the water flow meters will be cut into both the heating circuit and the domestic hot water output. Pairs of temperature sensors will go onto the incoming and outgoing pipes of both circuits. By measuring flow and temperature difference, I can work out exactly how much power the boiler is actually putting out. At the same time, I will measure the overall gas consumption at the house gas meter (luckily mine has an impulse at the lowest gear).
Most of the time (during winter) the gas will be used to heat the house - with brief periods for hot water, and for cooking in the evening. I know when we're using gas for hot water, because the flow in the heating circuit stops, and starts in the hot water circuit. But what about cooking?
That took some thinking (I considered a camera above the hob, or sensors on the cooker controls), but then I realized that I can learn a model of the efficiency of the boiler, probably dependent on outside temperature, maybe also return flow temperature. That model can be calibrated with data from times when I know I am not cooking (i.e. most of the day). Knowing the power output at any time, I can compare the gas consumption predicted by the model with that measured at the meter point - any additional gas used will have gone into cooking.
That way I can use inexpensive water meters to create virtual gas meters. And know exactly how much of our gas consumption went onto heating, hot water, and cooking.
(Virtual sensors and data driven modelling is my research area).
Saturday 10 March 2012
Shipping Charges
I want to move the project, so I've ordered more bits and pieces today.
First, since it doesn't look as if the tablet can be convinced to act in host mode, I need a USB host-capable kitchen node. There's a great new device out that could do this very well, and very cheaply - the Raspberry Pi has USB host, SPI, I2C and GPIO ports enough for what I need. But it looks as if even existing orders won't be fulfilled before April, current ones much later. I don't want to wait (though I might order one anyway). I can't use USB host shields (the SPI bus is needed for the wireless), so the only option is the Arduino Mega ADK. Overkill for what I need (with over 50 digital and 16 analog ports) expensive (certainly compared to a jeenode or a Pi, and even the tablet), and I still have to add an RMF21B wireless board; but it's a way forward. That's coming from the only UK shop I could find that actually has one in stock.
Then there's the wireless module, that comes from Jeelabs (as Seeed never did do the breakout board) in Holland.
I need some water flow sensors (also Seeed Studio) but the only place that has the 3/4 inch version that fits our heating circuit is a place in France.
And finally yet another (UK) place for some basic wires, resistors, LEDs, plugs etc.
I feel like I am paying more on postage than on parts...
First, since it doesn't look as if the tablet can be convinced to act in host mode, I need a USB host-capable kitchen node. There's a great new device out that could do this very well, and very cheaply - the Raspberry Pi has USB host, SPI, I2C and GPIO ports enough for what I need. But it looks as if even existing orders won't be fulfilled before April, current ones much later. I don't want to wait (though I might order one anyway). I can't use USB host shields (the SPI bus is needed for the wireless), so the only option is the Arduino Mega ADK. Overkill for what I need (with over 50 digital and 16 analog ports) expensive (certainly compared to a jeenode or a Pi, and even the tablet), and I still have to add an RMF21B wireless board; but it's a way forward. That's coming from the only UK shop I could find that actually has one in stock.
Then there's the wireless module, that comes from Jeelabs (as Seeed never did do the breakout board) in Holland.
I need some water flow sensors (also Seeed Studio) but the only place that has the 3/4 inch version that fits our heating circuit is a place in France.
And finally yet another (UK) place for some basic wires, resistors, LEDs, plugs etc.
I feel like I am paying more on postage than on parts...
Friday 9 March 2012
How green is your paper?
Last Monday, I went to Focus on Imaging at the NEC. It's great to have one of Europe's largest photo industry shows right at my doorstep.
Lots of great new kit (Canon's new flagship 5dMIII, new Nikons (but no Nikon charity raffle this year), the beautiful Fuji X-Pro 1), good talks, beautiful models, even minor celebrities (James and Ola from Strictly). And what excited me most? Paper.
Yes, the wonderful range of inkjet photo paper from a number of manufacturers. There's so much beautiful paper out there, both matt and glossy. I own an Epson 2880 printer, and I love printing and framing my own pictures. There is something special about making the physical artefact, at least a tiny bit back to the film and darkroom days of photography (I used to have a B&W darkroom as a teenager).
The next day we went to Stirchley Market where we sold a decent number of my postcards. That started me thinking: could I print the postcards myself?
At the moment, we have the photos printed by CEWE in Germany, and mount them onto recycled card stock . Commercial photo printers still use a chemical process onto modern photo paper (plastic), and produce chemical waste. Printing myself, apart from being a rewarding process, could be a lot more environmentally friendly. It might also be less labour intensive, and hopefully not much more expensive?
So, I started to find out about the environmental background of different papers. I asked the guys at www.on-linepaper.co.uk, and Simon Redgrove was very helpful, suggesting I look at Innova. I did, and asked them and some other suppliers about their environmental policy. This is what I found out so far - and it looks surprisingly positive:
Hahnemühle have a clear environmental policy (though I'd like that to be a bit more explicit) and support ecological projects. I love Hahnemühle's Bamboo paper - as the name implies, it's made from Bamboo, so potentially a green source. But it's a matt paper, so not ideal for postcards, and quite expensive.
Innova have a very clear environmental policy. They confirmed by email that all their stock is FSC sourced, though because the coating they put on the paper, the paper itself does not carry the FSC logo.
Similarly, St. Cuthberts Mill (also makers of Somerset papers) have a very clear environmental statement, claiming their stock is from 'sustainable sources'.
To my surprise, Permajet also claim that all their raw material is FSC certified. There's nothing about that on their web site, but they've promised to send me a statement from their mill. Permajet's paper is more budget-friendly, so I am really hoping they can document that claim (also, I want to switch to their continuous ink system).
Rag (cotton) paper is an interesting case - cotton production often has a negative impact (water use, pesticides, GM crop), but the material used is the outer husks, which are a by-product of the cotton industry. For that reason, this very good review of photographic paper argues that cotton paper is the best choice as long as you don't have certified FSC stock.
I haven't had a reply yet from Fotospeed, and there are a few more manufacturers I might contact.
In terms of costs, it turns out that the whole enterprise is a lot more difficult. Ink cost is just about OK when using a CIS (about 17p per A5 print, compared to 68p with Epson inks...). The paper however can quickly cost 1£ or more for an A4 sheet (to fold to A5). It looks like the only way to do it is to print onto 4x6 inkjet paper (about 12p) and stick that onto the recycled card stock...
Lots of great new kit (Canon's new flagship 5dMIII, new Nikons (but no Nikon charity raffle this year), the beautiful Fuji X-Pro 1), good talks, beautiful models, even minor celebrities (James and Ola from Strictly). And what excited me most? Paper.
Yes, the wonderful range of inkjet photo paper from a number of manufacturers. There's so much beautiful paper out there, both matt and glossy. I own an Epson 2880 printer, and I love printing and framing my own pictures. There is something special about making the physical artefact, at least a tiny bit back to the film and darkroom days of photography (I used to have a B&W darkroom as a teenager).
The next day we went to Stirchley Market where we sold a decent number of my postcards. That started me thinking: could I print the postcards myself?
At the moment, we have the photos printed by CEWE in Germany, and mount them onto recycled card stock . Commercial photo printers still use a chemical process onto modern photo paper (plastic), and produce chemical waste. Printing myself, apart from being a rewarding process, could be a lot more environmentally friendly. It might also be less labour intensive, and hopefully not much more expensive?
So, I started to find out about the environmental background of different papers. I asked the guys at www.on-linepaper.co.uk, and Simon Redgrove was very helpful, suggesting I look at Innova. I did, and asked them and some other suppliers about their environmental policy. This is what I found out so far - and it looks surprisingly positive:
Hahnemühle have a clear environmental policy (though I'd like that to be a bit more explicit) and support ecological projects. I love Hahnemühle's Bamboo paper - as the name implies, it's made from Bamboo, so potentially a green source. But it's a matt paper, so not ideal for postcards, and quite expensive.
Innova have a very clear environmental policy. They confirmed by email that all their stock is FSC sourced, though because the coating they put on the paper, the paper itself does not carry the FSC logo.
Similarly, St. Cuthberts Mill (also makers of Somerset papers) have a very clear environmental statement, claiming their stock is from 'sustainable sources'.
To my surprise, Permajet also claim that all their raw material is FSC certified. There's nothing about that on their web site, but they've promised to send me a statement from their mill. Permajet's paper is more budget-friendly, so I am really hoping they can document that claim (also, I want to switch to their continuous ink system).
Rag (cotton) paper is an interesting case - cotton production often has a negative impact (water use, pesticides, GM crop), but the material used is the outer husks, which are a by-product of the cotton industry. For that reason, this very good review of photographic paper argues that cotton paper is the best choice as long as you don't have certified FSC stock.
I haven't had a reply yet from Fotospeed, and there are a few more manufacturers I might contact.
In terms of costs, it turns out that the whole enterprise is a lot more difficult. Ink cost is just about OK when using a CIS (about 17p per A5 print, compared to 68p with Epson inks...). The paper however can quickly cost 1£ or more for an A4 sheet (to fold to A5). It looks like the only way to do it is to print onto 4x6 inkjet paper (about 12p) and stick that onto the recycled card stock...
Subscribe to:
Posts (Atom)