Following on from Part 1, we built our op-amp circuit and now it’s time to test it out. I ordered both the LM358 and OPA333 and began by testing the circuit on the LM358 as it was a DIP part.
I was powering the circuit from a 3V battery and was seeing something very strange; the output was 1.97V with no load connected.
It didn’t seem to match the circuit diagram above.
In my Adding EEPROM to the SATL post I briefly spoke about my multimeter not being about to measure the current of the SATL when it was writing to the EEPROM, mostly due to the fact that it happens so quickly in under 50ms. I decided that solving this problem would be my next project to work on.
My thoughts are to have an MCU sampling the ADC, use a resistor’s voltage drop to calculate the current then write the result to SRAM (instead of an EEPROM as it would take 10ms for each write). If possible, I would like it to also be powered by a 3V battery.
The maximum ADC samples per second that the ATtiny85 can do is 15,384 (15KSPS) at 200KHz which when compared to chips designed specifically for ADC that run at 200KSPS doesn’t seem like a lot, but in our case it’s a lot. The reason is that if we had a 64Kbit SRAM, it would only be able to store 8,192 samples which is just over half of the 15K samples per second, it would only record 0.5 seconds before running out of space. For a 256Kbit SRAM it would be 2 seconds.
Design attempt 1
Naturally I start up a circuit simulator and play around with different value resistors, resistors to simulate the load and find the voltage drops. Eventually I came up with a design that should be able to measure 10uA to 10mA using 3 resistors, 3 mosfets (for switching each resistor on/off) and use 2 ADCs.
I received a comment by Steve asking if I was going to combine the SATL and SAVL together. It sounded like a good idea to me so I’ve gone ahead and done just that.
The schematic was updated with the voltage sensing circuit, I added in a Mosfet so that we only draw power from the voltage source when needed and you’ll notice there are 2 jumpers – Temp and Volt. You can switch between logging temperature and voltage by completing the connection of the jumper and modifying a variable with button presses.
A user named tytower left me a comment about increasing the resolution range that the SATL uses when saving to the EEPROM from my value 90 to 255 to use 1 to 255 which has prompted me to include his suggestions in the SATL v3.0. Tytower explained that the temperature range is -40C to 125 which is 165 data points and if we take the maximum value of data stored in the EEPROM 255 (minus 1 for the value 0 being our stop bit) and divide by 165, we get 1.545 which means we can increase our resolution by 1.5x. If we divide 165 by 255, our new resolution is 0.65C degrees (before I just had it as 1C) and to keep things nice I’ll round up or down to 0 or 0.5.
Last week we looked at SoftI2C so we could use an I2C EEPROM on any of our AVR’s pins and now it’s time to apply that to the Standalone Temperature Logger as the internal EEPROM of 512 bytes is a bit limiting.
Identifying the pins to apply I2C to
The first step is to identify which 2 pins we can use, we rule out the USB pins PB1 and PB2. After some testing I found PB0 for the clock and PB4 for the data seem to work well. In SoftI2C the clock is only ever an output, we have a line like that already, the LED one PB0. The data line changes between an input with pull-up resistor and output, we also have a 100k pull-down to ground which you’d think should affect the pull up but we’ll see why it shouldn’t.
The reason it shouldn’t is because the internal pull-up resistor is between 20K and 50K per the datasheet page 167. Since it’s a low value resistor compared to our 100k resistor it makes a desirable voltage divider.
I’m thinking about updating the Standalone Temperature Logger to use an external EEPROM and since one of the ATtiny85 pins which correspond to hardware I2C/TWI is used by V-USB, a software implementation is the way to go. I found Soft I2C Master in Arduino code which allows any 2 pins to behave as an I2C interface.
Naturally I decided to convert that code to pure AVR which is available for download here – AVR_Soft_I2C_Master_v1.0
My modifications to the Soft I2C Master code are:
Made to work directly with AVR (De-Arduino existing code)
Changed from C++ to C
Added soft_i2c_eeprom_read_byte and soft_i2c_eeprom_write_byte
Example code
Here’s my example which writes 1 byte, reads that same byte and blinks the LED if the byte is the same.
The Non-Contact Blackout Detector has been updated to v1.1. The PCB got etched and you can see that the back of the board has a block of exposed copper which acts as our AC interference detector, it’s not as good as using wire. I’ve placed it into a small container.
Now I thought I’d link this project with the Nokia 3120 Keypad SMS Sender to make a project example named the Blackout SMS Sender. Download the Blackout SMS Sender_1.0.
In the above video you’ll see that the Blackout SMS Sender will SMS me once the power is out and then will SMS me once power is restored with how long the power was out for.
Modifications to the Nokia 3120 KSS were:
Use Timer0 interrupt every ~0.5 seconds to keep track of the time PB5 has been high for
Uses delay_ms again as we are using Timer0 to do interrupts and it won’t work well with the watchdog timer
Uses system sleep IDLE instead of PWR_DOWN as Timer0 won’t wake us up in PWR_DOWN
The Nokia 3120 Keypad SMS Sender has been updated to v1.1 to use the ATtiny261 and another ULN darlington array. View the project page.
v1.1 (29 January 2012) – Download
– Uses ATtiny261 to remove the extra transistor / mosfet circuit
– Uses a ULN2003A instead of 4 transistors
– Use a spare output on a ULN2003A to turn the phone on when we want to send an SMS
therefore saving the battery until we need it
– Use the watchdog timer instead of delay_ms
It’s been a while since I etched any boards but I got around to etching the Low Voltage Battery Monitor PCB yesterday.
I did have a slight issue with the 3V battery holder, it was supposed to be mounted on the top but the battery holder that I was using in Eagle was smaller than the real thing so I just mounted it on the bottom. Version 1.1 fixes this issue. Other than that it works well and I can now say is the largest PCB I’ve made.
Today we’ll be making a simple circuit to detect whether a blackout has occurred and when it has we can be alerted, it should be non-contact so we don’t need to plug it into a power point.
From my previous projects I’ve noticed that the ADC in MCUs can be quite sensitive, if you leave the ADC ungrounded and do a reading it fluctuates. When you connect a floating wire and then touch the wire or move it around you can see even more fluctuations.
We can use this to our advantage, by placing a high value resistor like 1 Megaohm to ground then when some interference is detected it will fluctuate from reading 0 (ground). After some testing, it’s best to read the ADC multiple times in a short amount of time rather than just reading once and relying on that reading. We’ll be using it to detect AC interference by placing it near power points or power cords.
AdvanceVGA – Play your GBA on the big screen! Swap out the LCD for our board, solder some wires, connect 5V USB and VGA and you’re ready to go.
GBxCart RW allows you to backup GB/GBC/GBA ROMs, save or restore game saves and re-write supported flash carts. Mini RW option available for GB/GBC only.
Wireless Gameboy Controller – Use your Gameboy, mGB, GBC, GBA, GBA SP, GB Micro, NDS and NDS Lite as a wireless controller on Windows, Linux, Raspberry Pi, etc, and on your NES, SNES, N64, Gamecube and Wii.