04-13-2008, 07:05 PM
|
#21 (permalink)
|
needs more cowbell
Join Date: Feb 2008
Location: ÿ
Posts: 5,038
Thanks: 158
Thanked 269 Times in 212 Posts
|
Buttons
Here is a simple approach, can be had from the 'shack
needed:
1 bag of 4 surface mount push button switches . Mine were $2 though the site says $4
1 general purpose dual pc board ~$2
Some hookup wore (cut open an old network cable or something).
Hot Glue gun
that really thin solder helps, especially inbetween the buttons. And sharpen up your iron first. Tin the iron with solder as soon as it can melt it, before it gets too hot and oxidizes.
Assembly:
Find a 12x3 group of copper circles on the board, by the edge but not on the edge. Score through the next row out in all 4 directions and snap off the extra. Tin the circles lightly that you will be using.
X=tinned
XOOXXOOXXOOX
OOOOOOOOOOOO
XOOXXOOXXOOX
Starting with the middle switch (leads touching one X each), surface mount the switches to the tinned copper spots, don't let the switch leads touch the other switches on the bottom, but do solder bridge them on the top. That That will be the ground.
Hold your breath, and (CAREFULLY) grind the top and bottom flush on the grinding wheel, bring in the sides to just outside the rings where the switches are connected.
Add the wires (and leave yourself plenty of wire for now). Pull them through the plain side and bend them over an appropriate switch leg and solder. Attach three signal wires and one for the ground.
grind the extra solder and wire off the top/bottom/
Straighten out the wires and run them to one end
Feed the wires through the top right hole in the lcd and position the buttons so the metal part is flush with the front of the lcd and they are straight, and the right side is flush with the right of the lcd board.
Pull the buttons back out just enough to put a thin layer of hot glue on the bottom of the buttons, and quickly but accurately put them in their final position. If your happy with their position and protrusion from the lcd, squirt in (caulk style) some hotglue to fill in behind the button boar.
coding:
In your code, you can use the internal pullup resistors via:
pinMode(pin, INPUT); // set pin to input
digitalWrite(pin, HIGH); // turn on pullup resistors
then attachInterrpupt (pin, function, FALLING) and or with the "button has been pressed" flag.
Hookup, the ground goes to ground and the signals go to the pin they control.
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
Last edited by dcb; 06-21-2010 at 10:39 PM..
|
|
|
Today
|
|
|
Other popular topics in this forum...
|
|
|
04-13-2008, 07:16 PM
|
#22 (permalink)
|
needs more cowbell
Join Date: Feb 2008
Location: ÿ
Posts: 5,038
Thanks: 158
Thanked 269 Times in 212 Posts
|
(EDIT, this is not current information)
Oh, and here is the LCD connection setup I used to preserve the multipurpose ports
Code:
NC=Not Connected
LCD pin 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
Arduino Pin GND 5V 13 12 8 7 NC NC NC NC 4 6 0 5 5V GND
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
Last edited by dcb; 05-05-2008 at 12:31 PM..
|
|
|
04-13-2008, 10:18 PM
|
#23 (permalink)
|
Batman Junior
Join Date: Nov 2007
Location: 1000 Islands, Ontario, Canada
Posts: 22,530
Thanks: 4,078
Thanked 6,978 Times in 3,613 Posts
|
Nice placement for those 3 buttons.
|
|
|
04-14-2008, 09:12 AM
|
#24 (permalink)
|
needs more cowbell
Join Date: Feb 2008
Location: ÿ
Posts: 5,038
Thanks: 158
Thanked 269 Times in 212 Posts
|
FYI, dont take the pin assignments to seriously yet. The arduino has blocked external interrupts on most of the ports and it *might* require some rewiring.
I'm reading some things that say arduino only allows two external interrupts, and obviously we need those for the injector and the vss. the atmega can support lots more external interrupts, so it probably just needs a little digging, and dipping into AVR.
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
Last edited by dcb; 04-14-2008 at 09:29 AM..
|
|
|
04-14-2008, 10:46 AM
|
#25 (permalink)
|
needs more cowbell
Join Date: Feb 2008
Location: ÿ
Posts: 5,038
Thanks: 158
Thanked 269 Times in 212 Posts
|
interrupt vectors
2 0x0002 INT0 External Interrupt Request 0
3 0x0004 INT1 External Interrupt Request 1
4 0x0006 PCINT0 Pin Change Interrupt Request 0
5 0x0008 PCINT1 Pin Change Interrupt Request 1
6 0x000A PCINT2 Pin Change Interrupt Request 2
arduino board mappings:
INT0 = digital pin 2
INT1 = digital pin 3
PCINT0= digital pin 8
PCINT1= digital pin 9
PCINT2= digital pin 10
PCINT3= digital pin 11
PCINT4= digital pin 12
PCINT5= digital pin 13
attachInterrupt only works with INT0 and INT1, so need to (INT0 example, translate for PCINT):
<chickenscratch>
#include <avr/interrupt.h>
...
int sensePin = 2;
...
ISR(INT0_vect) {
value = digitalRead(sensePin);
}
...
setup()
// Global Enable INT0 interrupt
GICR |= ( 1 < < INT0);
// Signal change triggers interrupt
MCUCR |= ( 1 << ISC00);
MCUCR |= ( 0 << ISC01);
}
</chickenscratch>
Don't know why there are not interrupt vectors for all the PCInts yet.
Note: in an ideal place we would use 6 external interrupts, 3 buttons, 1 injector signal, 1 vss signal, and one ignition power. But I recon we can poll the buttons and the ignition power if absolutely necessary.
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
Last edited by dcb; 04-14-2008 at 10:53 AM..
|
|
|
04-14-2008, 11:58 PM
|
#26 (permalink)
|
needs more cowbell
Join Date: Feb 2008
Location: ÿ
Posts: 5,038
Thanks: 158
Thanked 269 Times in 212 Posts
|
Note: I Updated the pin assignments on the freeduino serial processor draft to just use pins 2 and 3 (INTR0 and INTR1), and those do seem to respond to the buttons anyway. I'm going to move LCD wire connected to Pin 2 to pin 0 and we can assure ourselves of VSS and Injector signals that way by reserving pins 2 and 3 respectively.
I think the guino should try and dip into AVR and get more interrupts going for the buttons though, it *should* be easier than polling, and less flakey. But if someone wants to come up with a "wait" that can guarantee one second accuracy on the main loop but still do things like poll buttons while it is "idle", then that is cool.
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
|
|
|
04-15-2008, 01:40 PM
|
#27 (permalink)
|
Master EcoModder
Join Date: Dec 2007
Location: Norfolk, Va. USA
Posts: 869
Thanks: 14
Thanked 33 Times in 28 Posts
|
I'm still lurking,
waiting for a day when I would have something intelligent to add,
You guys are over my head, but I am patiently waiting the day you post schematics and parts list.
Thanx,
S.
__________________
When you are courting a nice girl an hour seems like a second. When you sit on a red-hot cinder a second seems like an hour. That's relativity.
Albert Einstein
|
|
|
04-15-2008, 02:46 PM
|
#28 (permalink)
|
EcoModding Apprentice
Join Date: Dec 2007
Location: Ventura, Ca
Posts: 112
Thanks: 1
Thanked 9 Times in 7 Posts
|
Well I've made miniscule progress, but heh, progress. I've been waiting and watching every day for the board I ordered to come in. I finally went to the Post Office, multiple times and they told me the package had already been delivered, like a week earlier. I checked here in the office and nobody knows what I'm talking about.
Someone finally found the package mixed in with some magazines. I presumed it was in a box and it came in a plain white plastic padded bag, so it was just presumed to be a bag.
On the inputs, if we can run the injector and the speed inputs to interupt pins on the PC, that would be better than not. The problem on the injector is that we need to measure two things, relative to the signal. First, we need to measure how long the injector is on, each cycle and second, we need to measure how long it is before the next cycle, which will give us the frequency or period of time the cycles occur, each second. This is effectively, also the same number as the rpm, unless the car is coasting, in gear, injectors off.
The problem on the injector timing is that effectively we need to measure a falling edge signal, have timing to a leading edge and then have timing to the next falling edge. Generally on edge triggered inputs, you can set it up to do one, or the other, but not both, but I haven't gotten far enough to look into that, yet.
|
|
|
04-16-2008, 10:12 AM
|
#29 (permalink)
|
needs more cowbell
Join Date: Feb 2008
Location: ÿ
Posts: 5,038
Thanks: 158
Thanked 269 Times in 212 Posts
|
Quote:
Originally Posted by Whoops
Generally on edge triggered inputs, you can set it up to do one, or the other, but not both, but I haven't gotten far enough to look into that, yet.
|
on the ATMega, there is an interrupt mode called "CHANGE", which gets triggered on high2low and on low2high. We probably need to use that one and do a digitalRead(injPin) first thing in the interrupt, or otherwise toggle a flag, or both. I should probably reference this from the signal processing thread.
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
Last edited by dcb; 04-16-2008 at 10:27 AM..
|
|
|
04-16-2008, 11:03 AM
|
#30 (permalink)
|
Batman Junior
Join Date: Nov 2007
Location: 1000 Islands, Ontario, Canada
Posts: 22,530
Thanks: 4,078
Thanked 6,978 Times in 3,613 Posts
|
Quote:
Originally Posted by dcb
In your code, you can use the internal pullup resistors via:
pinMode(pin, INPUT); // set pin to input
digitalWrite(pin, HIGH); // turn on pullup resistors
|
A little OT (and revealing my noobness on the topic)....
1) I didn't know what a pull up/down resistor was until recently.
2) This simple tutorial shows an external pull up resistor in a test button circuit. http://www.arduino.cc/en/Tutorial/Button
So ... the external resistor isn't strictly needed for that tutorial?
|
|
|
|