Show Posts
Pages: [1] 2 3 ... 7
1  Using Arduino / Microcontrollers / Re: ATTiny85 pin-change interrupt on pin 3 makes pin 2 go high on: June 20, 2014, 12:21:27 pm
No it doesn't, and that should clearly be PCINT0_vect. Thank you, thank you, thank you.
Problem solved!
My what strange behavior from this! I kind of expected to get a compiler error from an invalid vector id.
2  Using Arduino / Microcontrollers / ATTiny85 pin-change interrupt on pin 3 makes pin 2 go high on: June 20, 2014, 12:52:36 am
I'm trying to use pin change interrupts on the ATTiny85 for use with the RC switch library to make a little 315MHz RC decoder unit. Two pins are being used for my A/B channel outputs (0,1), one for a LED out(2), the RX data pin(3),  and a program button (4) input.
I worked the code out on a 328 using pin change interrupts and everything worked fine, then I modified the register and pin values appropriately for the ATTiny85, and uploaded the code to my board. The curious thing is that the pin change interrupt (not the handler!) seems to be making the LED pin (PB2) go HIGH (and quite  possibly other pins as well I suspect).

I commented out all of the RCSwitch code and through process of elimination determined that simply enabling the interrupt, without even attaching my handler allows the "bug" as described below to be reproduced.

  My RX module is mounted on a socket so I can unplug it. Doing so makes PB2 go LOW again and everything seems normal (button/led programming works fine sans RC functionality). Attaching a floating jumper wire to the interrupt enable pin (PB3) causes PB2 to go HIGH,  Connect the jumper to +5 or GND and PB2 goes LOW again!

Here's my sample code:
#include <avr/io.h>
#include <avr/interrupt.h>

#define REM_DOWN   0
#define REM_UP     1
#define RSET_LED   2
#define RX_PIN     3
#define PGM_BUTTON 4

//commenting this whole  thing out has no effect
ISR(PCINT3_vect) {  // Interrupt Function
//  mySwitch.handleInterrupt();
}// end ISR

void flashLED(byte n)
  for (byte i=0;i<n;i++) {
}// end flashLED

void setup()
// read comments below about these lines
// somehow a pin change event on THIS pin (PB2), triggers the subsequent buggy behavior from  PCINT3

  GIMSK  |= (1<<PCIE); // enable Pin Change interrupts
  PCMSK |= (1<<PCINT3); // enable PB3 which PCINT3 is on
  sei(); // set Enable Interrupts

//  flashLED(1);

void loop()

The interesting thing about this sample code is the the effect of changing the RSET_LED pin (PB2). As show above with the "quick" low-high-low again status of PB2 , it ends up noticeably flickering in response (presumably) to the random voltage fluctuations on PB3. Uncomment the flashLED call at the end and PB2 ends up continuously lit, with no noticeable flicker (even though it should just be LOW).

Any help with these Gremlins is greatly appreciated!
3  Using Arduino / Networking, Protocols, and Devices / Re: Problem reading TTL serial data from weather station on: April 04, 2013, 08:30:24 pm
Well I've managed to figure out that the signal has to be inverted (couldn't find anywhere that just came out and said that), by rigging a very simple NPN transistor circuit with a pull up resistor on the collector output. This lets the Arduino see the right values, but it doesn't have the best wave form on a DSO. I tried a cmos CD4049 hex inverter and a SN7404 TTL hex inverter, but couldn't make either of those work.
I've tried a couple MAX3232 converters but the 5V TTL level semi-RS232 input from the weather station doesn't seem to be strong enough to get a useful output.
Any suggestions?
4  Using Arduino / Networking, Protocols, and Devices / Problem reading TTL serial data from weather station on: April 04, 2013, 02:44:46 pm
This is supposed to be easy, but I've been banging my head on it. Please help me figure out what I'm doing wrong!
I've got a weather station that sends out data at 2400 and I'm using an Arduino Mega 1280 board. When the weather station is hooked up to an old usb/serial converter I've got then I can capture the correct data on a PC, but when I connect it directly to the Mega's RX2 (in this case) I can't make sense of the data.
I've got the Mega programmed with a simple pass-thru serial program that reads from Serial2 and writes to Serial to try and see what's going on.
Trial and error along with a DSO showed that a "signal indicator" LED w/1K resistor on the line is needed to get a good square wave.  Without that little circuit, the Mega just sees junk, with that circuit it sees repeating junk, which is only arguably better!

Here's what I should see (and do see on the PC):


Here's what I see on the Mega instead (byte values, comma delimited):

There's no obvious logic that could  change the 111 into 33 (ascii '!') and also change the other digits into 48 (ascii '0'), and I really don't know what else to try.

Any help is appreciated.
5  Using Arduino / General Electronics / Re: Question about Analog Ports.... on: February 02, 2013, 02:59:59 pm
A frequency analysis of the floating values would probably be similar to white noise, which has a mix of all frequencies. With a normal impedance connection established to the ADC, depending on the signal, one would expect the high frequency component to drop substantially.
Perhaps a better way of consider it would be a first or second derivative approach. If differences in the rate of change of value are high enough, then that would indicate a floating (open port) condition.
6  Community / Exhibition / Gallery / Re: Voltage controlled switch with an ATtiny85 on: February 02, 2013, 02:51:21 pm
It works basically like you described.
The 6-35v connection is for driving something like a relay, or a small dc pump. Maybe you want a 12v relay, maybe you want a 24v relay. Whatever the input voltage is gets applied to the output. The 78L05 provides power for the ATtiny85, which draws such little power that it doesn't matter that a linear regulator is taking it down to 5v from 24V. The regulator doesn't get hot at all.

Depending on your application you might choose to connect your PV voltage (pre-charge controller) to the Input, or perhaps your battery voltage (post-charge controller). is my active web site.
7  Using Arduino / General Electronics / Re: Basic Ohms law problem on: February 01, 2013, 10:47:55 pm
The resistor would have to precisely match your current draw to get the right voltage drop. Given your predicament the easiest route might be to just burn the extra power with a 5v zener diode to lower the voltage.
8  Using Arduino / General Electronics / Re: Question about Analog Ports.... on: February 01, 2013, 10:44:18 pm
I've used a so called single-pole low pass digital filter before, and it might be worth a try to create a high-pass filter that you could apply to the adc input, and based on the noise level you could detect the floating input condition. Not sure how to code that off-hand, but that should point you in a good direction.
I've tried using 3.5mm stereo jacks with built-in switches for detecting a connection and it was so problematic that I gave up. This could be a good idea for a "smart" input.
9  Using Arduino / General Electronics / Re: PWM to analog... is this just too Rube Goldberg? on: February 01, 2013, 10:33:24 pm
I play guitar so that helps me understand what you are getting at. You've got some sort of voltage-controlled analog effect box circuit that you'd like to put under digital Arduino control by using PWM and an R/C filter to generate the control voltage for the effect. I've thought of that before, and it would seem to be fine in theory (if your circuit is happy with 0-5V for your analog control, and doesn't take too much current); otherwise as mentioned you'll want an op amp to get a different range.
10  Community / Exhibition / Gallery / Voltage controlled switch with an ATtiny85 on: February 01, 2013, 10:23:52 pm
I just wanted to share my latest project with the Arduino community. I've created a little voltage controlled switch using an ATtiny85, and of course tried to incorporate all the best practices that I could pickup from this forum. This circuit is primarily intended to be used in solar power applications. For example you might want to monitor battery or panel voltage and then trigger a relay at a set voltage to send power to some power hungry device as long as the voltage doesn't drop.

Part of the fun was using a couple LEDs to flash out the voltage set-point value, and just a couple buttons to handle all the functionality. The voltage divider portion of the circuit has a 4.7v zener protection diode, and uses a small capacitor for ADC impedance balancing with the 100K input resistance. I've built some with a 24V range, and some with a 50V range. A PNP TIP127 switches the positive supply voltage for the output circuit and should have adequate current capability for most relays or directly driving small fans and motors less than 2A. A small diode provides at least some protection to the microprocessor from the output circuit in the case of transistor failure (Ha! looking close at the picture I see I cheated and used a short jumper wire instead of the protection diode on this board!), and a 3A blocking diode prevents damage from reverse polarity power connection. The 78L05 regulator handles a wide input range allowing the board to work on any supply voltage from 6 to 35VDC.

On this first version I tried to use the RESET pin for an adc input since the diagram I had looked like that was possible, and I'm still not sure of that would work, but I didn't want to set the fuses to try it. So this version doesn't have any hysteresis control or an inverted mode option. The next version will feature a 4bit R-2R resistor network to read all four switches with just one analog input, and leave the RESET pin open.
11  Community / Exhibition / Gallery / Solar tracker with ATTiny85 on: March 05, 2012, 03:03:53 am
I finally got around to having some fun with the ATTiny85 and created a simple little solar tracker. I call it the TinyTracker The ATTiny uses it's A/D converters to measure the voltage from a couple green leds used as light sensors, and uses its pwm pins for controlling an H-bridge to drive a motor. The voltage regulator takes up to 36v so motor power can be used for logic too, i.e. just one power connection. I made sure to use at least 105C rated capacitors so hopefully it will be OK in the summer sun. What's really amazing is that I designed the board in a day, wrote the program in an hour or less, and the darned thing worked the first time I tried it!
I've trimmed the vane down a bit from the picture (it's just made from cardboard). It's a bit optional really, but it does improve accuracy. I'm still trying to decide what the best enclosure is. So far it's a dummy security camera dome sealed on top of a double-gang outdoor PVC junction box, but sideways in a clear jar with a lid for the base works pretty good too.
I'm selling assembled boards as well as linear actuators at my website in case anyone is interested.
12  Using Arduino / Project Guidance / Re: Arduino controlled robot arm on: February 10, 2012, 10:41:23 am
Arduino is up to the task if you are! I would recommend writing your own motor library, but there are many out there and you may be able to find a servo library that serves your purpose.
The key is to think things through. Draw your diagram of how things will work, and get rid of the black-box components if you know what I mean.
Example: move motor 1 degree. How is motor controlled? PWM? that has a resolution of 512. What is the range of motion of the motor? Divide range of motion by 512 to find motor resolution.
Likewise imagine a program to let you record a series of movements by repeatedly moving the motors to a certain position, pressing a button and storing the coordinates in EEPROM, maybe even add timing information. If you need more memory then you could go to an SD card system (which would require you to implement at FAT16 file to read/write the data from/to)
Use the force, meditate on the various functions and their variables, then you can write the code! The playground has lots of examples of things once you get down to specific questions of hardware and software implementation.
Good luck.
13  Using Arduino / Sensors / Re: What happens if I put a sensor in a digital input instead of an analog on: February 09, 2012, 10:21:51 am
Yeah that will work,but your reduced resolution is ON or OFF. At whatever voltage the Arduino's logic threshhold is set to, your digital input will invert it's digitalRead() value. You won't be able to measure distance per say, but you will know when something is within a particular radius. Just trim your analog value to set this to the desired distance.
14  Using Arduino / Sensors / Re: how to use a light frequency sensor on: February 09, 2012, 10:14:56 am
This doesn't measure frequency, just intensity. The frequency it outputs, is proportional to the intensity. It's also basically an offset square wave that changes between HIGH and LOW logic states (+5v and 0v). So the quesion is: how do you measure frequency with the Arduino? The simplest technique I can think of is to use the period() function. I would guess that you need to call it twice since the first call may get an incomplete cycle. Frequency is the inverse of period, so then just use the specs in the datasheet to convert Frequency into light amplitude.
Why would someone want a sensor like this? Because they don't have a MCU with analog inputs! The Arduino analog inputs make many more, much simpler light sensors possible.
If you really wanted to measure light frequency, that sounds both very interesting and very tricky. I don't know of any solid state solutions, and digital spectrometers just sound expensive. Maybe a CCD could be hooked up to a prism setup and software could analyze the picture to do a frequency analysis. That sounds like an interesting experiment.
15  Community / Products and Services / Re: Solar Mega - an Arduino MEGA shield with LCD & RTC for motor control and sensing on: February 06, 2012, 12:50:34 am
It seems like all the fancy waterproof connectors cost as much for a working male/female pair as an Arduino, or more, so I decided to go with a sealed enclosure with room for connections and waterproof fittings. The only way that seemed practical in the end, and that allowed me to have 5 A/D fully bucked IO ports was the 3.5mm jacks, but I knew they had to be protected since any type of normal jack that plugs are commonly available for could let moisture get to the electronics.

 Here's a picture of the controller in it's enclosure. Some may recognize it as a polycarbonate waterproof box for kayaking, etc. made by Outdoor Products. The membrane keypad overlay is designed for exposure and allows user control without opening the case. Double latches and a gasketed seal keep the door water tight, and I drill out for a watertight conduit fitting. I use 3/4" near the control unit, and then switch to 1/2" for the branch lines (motor, power, sensor, etc.). There's enough room in the box to make all necessary connections, and a packet of silica gel prevents condensation. I like using neoprene rubber stoppers for grommets in the end of the conduit body where any final connections are made before going out into the weather.  The stoppers get drilled out appropriately and then the wire is sealed with silicone. Flex conduit and regular pvc conduit are so cheap, it seems like a no brainer to protect as much of everything as possible, and it makes it look nice too.
I'm waiting right now to get my official franchise license from the state so I can open my webstore at

It may not walk or talk, but a digital solar tracker is a type of robot, moving and responding to it's environment according to time and conditions. The trick in implementation is to achieve industrial-like quality without a huge budge, making a robot that lives outside quite a design challenge, but it feels like I've got most of the serious issues addressed (hopefully!)
Pages: [1] 2 3 ... 7