the12volt.com spacer
the12volt.com spacer
the12volt.com spacer
the12volt.com spacer
icon

single pulse on/off latch relays


Post ReplyPost New Topic
< Prev Topic Next Topic >
trbolexis 
Member - Posts: 22
Member spacespace
Joined: February 24, 2012
Location: California, United States
Posted: May 24, 2012 at 12:07 PM / IP Logged  
Looks like a programmable chip would be better .. Let me look into this.
trbolexis 
Member - Posts: 22
Member spacespace
Joined: February 24, 2012
Location: California, United States
Posted: May 24, 2012 at 4:27 PM / IP Logged  
Okay,
The microcontroller is the way to go. However I need a GREAT deal of assistance with programming the chip.
On powerup, the chip should output 203 ADC at 'X' Pin. Then on a Pulse in, on 'Y' Pin, it should output 406 ADC at the initial pin (X). On next pulse in on 'Y', output should be 609 ADC on pin X.
So, with button press, desired outputs would be as follows
Press1, 204ADC (1 Volt)
Press2, 408ADC (2 V)
Press3, 612ADC (3 V)
Press4, 816ADC (4 V)
Press5, 1020ADC (5 V)
Now, my next question. Is there anyway to write the last state (ADC output) to back to the chip in order to retain its output the next time its powered up?
This is all excellent info so far! Thank you!
trbolexis 
Member - Posts: 22
Member spacespace
Joined: February 24, 2012
Location: California, United States
Posted: May 24, 2012 at 4:54 PM / IP Logged  
Upon further reading, I've learned that the 08M2 must use PWM on an output pin to create a pseudo analog voltage output with a Cap And resistor.
Can someone help me on designing such a circuit? i.e. what size cap and resistor? Also, is this going to be a trial and error sorta deal to figure out the appropriate PWM frequency?
oldspark 
Gold - Posts: 4,913
Gold spacespace
Joined: November 03, 2008
Location: Australia
Posted: May 24, 2012 at 7:01 PM / IP Logged  
No, you use the DAC output - Digital to Analog, not the ADC (Analog to Digital).
The 08M2 is the first 08 with a DAC. Not that I have confirmed its existence - apparently the documentation is confusing. (IE - the prelim docs specify a DAC but product specs don't - though it was a few months ago that I looked...)
If using PWM, the RC constant needs to be much greater than the PWM frequency. Something like 1mS to 1Sec should be enough (unless 1 sec is too slow for your EFI reaction...)
trbolexis 
Member - Posts: 22
Member spacespace
Joined: February 24, 2012
Location: California, United States
Posted: May 24, 2012 at 7:10 PM / IP Logged  
Ahhh ... I read your post after perfecting my code. LOL
[code]symbol varA = b0
symbol varB = b1
symbol varC = b2
symbol varD = b3
symbol varE = b4
symbol varF = b5
symbol varG = b6
symbol varH = b7
symbol varI = b14
symbol varJ = b15
symbol varK = b16
symbol varL = b17
symbol varM = b18
symbol varN = b19
symbol varO = b20
symbol varP = b21
symbol varQ = b22
symbol varR = b23
symbol varS = b24
symbol varT = b25
symbol timer = time
let dirsC = %00000001
main:
label_106:
prc_STAGESELECT:
read 0,varA
if varA = 0 then label_143     'Compare command
if varA = 1 then label_145     'Compare command
if varA = 2 then label_151     'Compare command
if varA = 3 then label_152     'Compare command
if varA = 4 then label_153     'Compare command
goto label_106
label_153:     goto prc_IBOOST5     'Goto
loop0:
goto loop0
prc_IBOOST5:
label_133:     pwmout 2 , 99 , 400
if pinC.1 = 1 then label_135     'Decision command
goto label_133
label_135:
if pinC.1 = 0 then label_136     'Decision command
goto label_135
label_136:     pause 500     'Wait command
let varA = 0      'Expression command
write 0,varA
goto prc_STAGESELECT     'Goto
loop1:
goto loop1
label_152:     goto prc_IBOOST4     'Goto
loop2:
goto loop2
prc_IBOOST4:
label_125:     pwmout 2 , 99 , 320
if pinC.1 = 1 then label_127     'Decision command
goto label_125
label_127:
if pinC.1 = 0 then label_128     'Decision command
goto label_127
label_128:     pause 500     'Wait command
let varA = varA + 1     'Inc command
write 0,varA
goto prc_STAGESELECT     'Goto
loop3:
goto loop3
label_151:     goto prc_IBOOST3     'Goto
loop4:
goto loop4
prc_IBOOST3:
label_117:     pwmout 2 , 99 , 240
if pinC.1 = 1 then label_119     'Decision command
goto label_117
label_119:
if pinC.1 = 0 then label_120     'Decision command
goto label_119
label_120:     pause 500     'Wait command
let varA = varA + 1     'Inc command
write 0,varA
goto prc_STAGESELECT     'Goto
loop5:
goto loop5
label_145:     goto prc_IBOOST2     'Goto
loop6:
goto loop6
prc_IBOOST2:
label_95:     pwmout 2 , 99 , 160
if pinC.1 = 1 then label_101     'Decision command
goto label_95
label_101:
if pinC.1 = 0 then label_115     'Decision command
goto label_101
label_115:     pause 500     'Wait command
let varA = varA + 1     'Inc command
write 0,varA
goto prc_STAGESELECT     'Goto
loop7:
goto loop7
label_143:     goto prc_IBOOST1     'Goto
loop8:
goto loop8
prc_IBOOST1:
label_80:     pwmout 2 , 99 , 80
if pinC.1 = 1 then label_82     'Decision command
goto label_80
label_82:
if pinC.1 = 0 then label_114     'Decision command
goto label_82
label_114:     pause 500     'Wait command
let varA = varA + 1     'Inc command
write 0,varA
goto prc_STAGESELECT     'Goto
loop9:
goto loop9
[/code]
oldspark 
Gold - Posts: 4,913
Gold spacespace
Joined: November 03, 2008
Location: Australia
Posted: May 24, 2012 at 7:47 PM / IP Logged  
Not that I'm into the coding yet... And not that I understand your varB-T declarations etc.
But yes, setting one pin/leg as output.
Then I'd output the 1V, clear the "keypress" counter, and loop awaiting interrupt or loop-poll the switch input. (switch = key etc - whatever names suit you)
Implement the switch debounce code (as per some of my previous web links) and increment the keypress counter -cum- output voltage.
Check that switch=0 (after debounce) before the next increment.
Decide if you want the output change to occur on switch/key press or release (ie, many PC triggers are on button release).
Loop for switch polling or next interrupt.
(The older 08s did not have interrupts.)
Later add a pin to drop of output voltage etc (eg, and engine-blown alarm or temp sensors etc to kill the boost). That's the beauty of it - it's just additional programming...
And the 08M2 could be in the EMS and use its +5V hence minimising noise and components. (They only use mA...)
Only 2 or 1 wires out - ie, to the switch, & for serial programing - though those 2 could be combined. Plus optional gnd for the switch and serial...
I'd use the DAC output, but PWM with RC is "the same".   
Oh - and I'd use meaningful labels - eg, debounceLoop, keyWait, incKyCount, incVout etc.
But that is all to taste and varies not only with experience, but even as the program evolves. (EG - deciding to move from item-function-instance to function-item etc (incKey, incOut or keyInc, outInc, or Key+, Out+ etc etc.)
LOL - when I look back at my early "program comments" that were mere English descriptions of the commands or mnemonics with label-1 & loop-3 etc...
Later programs were a description for each "section" (if needed) followed by the code which had rare comments. Usually the variable and goto and loop names/labels were self explanatory.
KPierson 
Platinum - Posts: 3,527
Platinum spaceThis member consistently provides reliable informationspace
Joined: April 14, 2005
Location: Ohio, United States
Posted: May 24, 2012 at 9:48 PM / IP Logged  
As far as remembering the last state you should be able to store the current value in an EEProm register and call that register at each start up. If you plan to push the button a lot then you should look in to a circular EEProm programming configuration as most EEProm have a fairly low write/rewrite life cycle (100,000 or so writes).
If the chip has a dedicated DAC I would use that, eliminate the complexity of the PWM and conversion. However, the PWM through an RC circuit should be more then adequate for your application.
Are you planning on using this to adjust a boost controller? If so, I would recommend some sort of visual output so you always know what the current setting is.
Kevin Pierson
trbolexis 
Member - Posts: 22
Member spacespace
Joined: February 24, 2012
Location: California, United States
Posted: May 25, 2012 at 2:05 AM / IP Logged  
It is EXACTLY for a boost controller.
Im really digging all this information guys!
SO, I've dove in head first and here's what I've got.
single pulse on/off latch relays - Page 3 -- posted image.
single pulse on/off latch relays - Page 3 -- posted image.
I have actually got the chip out-puting its current voltage to me via one if its analog inputs, through the code. I'm amazed.
I had no idea things like this were so accessible and easy for the DIY.
I have the low-pass filter setup as well (on the bread board) and using the PWM I can dial in the required V to the .01 place. Amazing!
The Arduino Pro Mini board however, does NOT have a DAC, so I am only able to use PWM with it. I would have love to run the 08M2 chip, but I'm impatient and was looking for a fast project - ha.
Im looking into an effective means of debouncing the push button currently, and I think I've found the software solution.
[quote]/*
Debounce
Each time the input pin goes from LOW to HIGH (e.g. because of a push-button
press), the output pin is toggled from LOW to HIGH or HIGH to LOW. There's
a minimum delay between toggles to debounce the circuit (i.e. to ignore
noise).
The circuit:
* LED attached from pin 13 to ground
* pushbutton attached from pin 2 to +5V
* 10K resistor attached from pin 2 to ground
* Note: On most Arduino boards, there is already an LED on the board
connected to pin 13, so you don't need any extra components for this example.
created 21 November 2006
by David A. Mellis
modified 30 Aug 2011
by Limor Fried
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Debounce
*/
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin = 13;      // the number of the LED pin
// Variables will change:
int ledState = HIGH;        // the current state of the output pin
int buttonState; // the current reading from the input pin
int lastButtonState = LOW;   // the previous reading from the input pin
// the following variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long lastDebounceTime = 0; // the last time the output pin was toggled
long debounceDelay = 50;    // the debounce time; increase if the output flickers
void setup() {
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
// read the state of the switch into a local variable:
int reading = digitalRead(buttonPin);
// check to see if you just pressed the button
// (i.e. the input went from LOW to HIGH), and you've waited
// long enough since the last press to ignore any noise:
// If the switch changed, due to noise or pressing:
if (reading != lastButtonState) {
    // reset the debouncing timer
    lastDebounceTime = millis();
}
if ((millis() - lastDebounceTime) > debounceDelay) {
    // whatever the reading is at, it's been there for longer
    // than the debounce delay, so take it as the actual current state:
    buttonState = reading;
}
// set the LED using the state of the button:
digitalWrite(ledPin, buttonState);
// save the reading. Next time through the loop,
// it'll be the lastButtonState:
lastButtonState = reading;[/quote]
Borrowed from http://arduino.cc/en/Tutorial/Debounce
oldspark 
Gold - Posts: 4,913
Gold spacespace
Joined: November 03, 2008
Location: Australia
Posted: May 25, 2012 at 8:17 AM / IP Logged  
The Arduino is overkill, but if it works...
What "amazes" me is the cost - the ~$4 8-pin 08M2 plus $2 78L05 regulator (+ 2 resistors) is cheaper and simpler (to construct) than the 14-pin 4017 etc. (That's ignoring the serial interface for programming - ie, a USB to serial if you new PC has no serial port.)
Then that any "circuit change" is merely a program change...
I used to think that using a transistor or 2, or a logic chip etc was easier than using relays for logic. But these PICs make a joke of any design.
trbolexis 
Member - Posts: 22
Member spacespace
Joined: February 24, 2012
Location: California, United States
Posted: May 25, 2012 at 9:17 AM / IP Logged  
I agree that the adruino is overkill. But at the xost of 13 bucks, and already having the usb to serial interface at home, it was still cost effective and will give the same results. I am going to be stocking up on M2 chips for future projects however.
Page of 4

  Printable version Printable version Post ReplyPost New Topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

  •  
Search the12volt.com
Follow the12volt.com Follow the12volt.com on Facebook
Friday, April 26, 2024 • Copyright © 1999-2024 the12volt.com, All Rights Reserved Privacy Policy & Use of Cookies
Disclaimer: *All information on this site ( the12volt.com ) is provided "as is" without any warranty of any kind, either expressed or implied, including but not limited to fitness for a particular use. Any user assumes the entire risk as to the accuracy and use of this information. Please verify all wire colors and diagrams before applying any information.

Secured by Sectigo
the12volt.com spacer
the12volt.com spacer
the12volt.com spacer
Support the12volt.com
Top
the12volt.com spacer
the12volt.com spacer