Extreme Newbie Question
chemania
Posts: 25
I am going to be using a BS2P40 to create a control system for a preamp. The thing will run an LCD, 12-4pdt relays, rf and button inputs. I know I will need 12v to run the LCD backlight and 5v for all logic and relays. I plan on using a 200w pc supply to power the whole thing. I plan on running the 5v for the relays directly from the pc supply.
Question is what should I run to where on the stamp? 12V on VIN, 5v on VIN, or 5v on VDD? I checked the supply and it runs 5.02v with 375mA load. Each relay nominally runs this load, max nominal load from relays should be less than 3 amps (given that no more than 9 will be energized at any one time). Oh, I am using a handful of ULN2803A's to drive the relays too.
More questions to come... [noparse]:)[/noparse]
thanks,
chemania
Question is what should I run to where on the stamp? 12V on VIN, 5v on VIN, or 5v on VDD? I checked the supply and it runs 5.02v with 375mA load. Each relay nominally runs this load, max nominal load from relays should be less than 3 amps (given that no more than 9 will be energized at any one time). Oh, I am using a handful of ULN2803A's to drive the relays too.
More questions to come... [noparse]:)[/noparse]
thanks,
chemania
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Do you have a Stamp Tester?
http://hometown.aol.com/newzed/index.html
·
OOPS u are correct.· I checked the data sheets and they are 50mA at max.· I misread mW as mA· ... stupid me.
>You didn't say how many buttons - you should be using a shift register to drive the 2803's - it will save you a lot of Stamp I/O lines.
Only going to use 4 buttons.· Volume up/dn, mute, input selector.· I have heard some talking about the shift register technique but know nothing about it.· Looks like it is time to search the archives again.
TNX,
Chemania
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Do you have a Stamp Tester?
http://hometown.aol.com/newzed/index.html
·
·· I have built dozens of controller-based Amplifier/Pre-Amplifer Systems over the years.· Alot of what you will be using is the same stuff I have used in the past...However, I am surprised by the 12 4PDT relays.· If it's for switching audio, might I suggest a slightly more elegant way of accomplishing this?· There are many audio switching chips available that can be controlled by the BASIC Stamp.· Some are serial control, others parallel.· This would not only provide cleaner switching of the audio, but will take less hardware and power consumption.
·· In my designs I've used one 12VDC relay to switch main power, and 2 5V PCB Relays to switch the tape monitor circuit.· All the input switching used to be done by 2 LM1037N's by National Semi, but alas, they're discontinued.· In any event, there are substitutes.
·· One other way I save precious I/O pins on the BASIC Stamp when I'm using an LCD display is to use a Serial Backpack.· This uses only 1 Stamp pin to use the LCD.· The ones I use provide extra I/O pins which are used to switch various non-critical hardware within the pre-amp, such as the LCD backlight, etc.
·· I must admit, you are the first person I have seen post about doing such a thing...I myself started back in 1991 doing it for friends and clients.· It can be an ambitious project the first time!
·· I almost forgot...Your power supply sounds like a little overkill...I have used a single transformer from Radio Shack in prototypes before...This supplies +12/-12V and +5VDC for the pre-amp and logic.· This is built from a 24VCT 2A transformer from Radio Shack, and provides the 3 supplies using a bridge rectifier, 2 regulators, and a few caps.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--==<{Chris}>==--
Post Edited (Chris Savage) : 2/11/2005 1:09:11 AM GMT
I am actually building a Class-A MOSFET balanced preamp and amp. Both projects are ongoing and currently in various stages of completion. I have done several amps and preamps before, each with its own specific fun feature, but have never attempted microprocessor control of this type before. I actually have a degree in Chemical Engineering with Major Emphasis on CAPD/CAPC. I have done some opto22 control systems (I actually have an old LC2 in the work shop, anyone remember how to program in FORTH??) in the past as well as systems using other "packaged" controllers, but that was decades ago (I teach HS chem and phy now). So yea, there are some steep learning curves to overcome but not insurmountable. In reading the reference manual (definite gEEk thing) I keep going...oh yea! I remember that!. I considered going with a pga2310 for the volue control but wanted to stick to a more purist approach.
Since this thing is balanced, I am using 5 4pdt relays to switch inputs (3 unbal inputs, tape monitor, and bal input) , so we get R+,R-,L+,L- switched. On unbal inputs the relays connect the + inputs and ground the -inputs. The preamp uses Super Symmetrical feeback and in researching the thing I found an idea for using 8 relays to create a 256 position shunt-type volume control. From what I have read on the subject it seems to work VERY well. So there you go. Actually 13 relays. I do plan on using a 1 pin backpack for the lcd. As for the PS, the audio section of the preamp runs at +-60V regulated. I have most of that supply done except for the regulation stages. Since I have a box full of old PC power supplies lying around here I just thought I would grab one and use it instead of trying to reinvent the wheel.
At this point that is about as far as I have gotten in the design, except for laying out a few lines of pseudo-code. I basically have pseudo-coded the input selector function, mute and volume functions. As I learn more about syntax and stamp features, I am having to go back and change things a bit. It is fun none the less. Controls was my first love, though I have not gotten to do any in years.
BTW Chris, knowing that you have done this before, you have become my new best friend!!!
That is about all I can think of for now,
Chemania,
PS - The reason I got these small signal relays is that I found 132 of them for 30 bux! I did have to remove them from a board and am in the process of testing them now. Up to this point they have shown very well. I have the input boards laid out and soldered up as well as the volume control. I am using 9 pin serial ribbon cable on standard 10 pin headers to hook everything up.
·· Unbalanced inputs changes everything...I don't know of any chips to handle that, however I myself prefer balanced signals anyway.· Another thing on the relays regarding power, is if you're only going to have a few on at a time, I still think you can get by with a smaller power supply.
·· My Pre-Amps use two different supplies running off a single transformer.· In the end you have +/- 12-15V (Depends on the design) plus the +5VDC for the logic, plus sometimes +12VDC for certain things.· But I have always packaged the Pre-Amp and Power Amp sections in different enclosures (Usually rack-mount style).· In early versions I used a standard MIDI cable (DIN-5) to connect the control signals to the Power Amp section, which has it's own power supply for the main amplifier (+/- 74V), as well as a small +5V/+12V supply for the Meters and Fan.· The audio was sent via standard patch cables.
·· Usually the only thing in the Power Amplifier enclosure besides the main amp board and power supplies is Power Output Meters, Cooling Fan (The amp gets quite hot!), temp sensor (Thermistor), mute control and Power Relay.· All these signals can be realized with the DIN-5.· Basically·one pin·sends temp data back (Analog).· That data is used to determine whether the cooling fan needs to be one (one more pin).· One pin controls the Mute Relay (Function of Hybrid Amp Chip/National Semi), which serves two purposes, one of which is a normal MUTE function, the other of which prevents turn on thumps.· One pin controls the Power Relay (Which turns on both supplies in the Power Amp cabinet).· The last pin is used for a common-ground for all these signals, although I could use the shield and make use of this last pin if I wanted.
·· The Pre-Amp has line-input meters which are very fluid and provide a measure of the input signal, whereas the Power Meters on the Amp show the actual power level going to the speakers.· In the past before I had a logic-controlled chip to control volume, I aquired a motorized volume control and used that.· It's a standar 100K Stereo POT with·Taper for loudness contour, but is driven by a motor.· Using relays for volume control never quite occurred to me, but it's an interesting concept, nonetheless.· I admire your ambition.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--==<{Chris}>==--
Paul
BTW - guys, I got the relay volume control running. Works great! Listening to it now on the computer. Using Debug to show the volume level. Thanks for the help. Now for the mute, input selector, and lcd..and then to get some boards laid out and installed.
Chemania
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--==<{Chris}>==--
' {$STAMP BS2p}
' {$PBASIC 2.5}
vol VAR Byte
prevol VAR Byte
OUTPUT 0
OUTPUT 1
OUTPUT 2
OUTPUT 3
OUTPUT 4
OUTPUT 5
OUTPUT 6
OUTPUT 7
INPUT 8
INPUT 9
vol=0
prevol=0
main:
IF IN8 AND vol < 255 THEN vol = vol + 1 ' volume up button
IF IN9 AND vol > 0 THEN vol = vol - 1 ' volume down button
IF prevol <> vol THEN DEBUG CLS,? vol, BIN(vol)
OUT7 = vol.BIT0 ' I know this section looks backwards but it made sense to me when I coded it!
OUT6 = vol.BIT1
OUT5 = vol.BIT2
OUT5 = vol.BIT3
OUT3 = vol.BIT4
OUT2 = vol.BIT5
OUT1 = vol.BIT6
OUT0 = vol.BIT7 ' probably should wrap this whole switching statement in an IF like the DEBUG statement
prevol = vol
PAUSE 75
GOTO main
Like I said, rough, but OK for an hour's work after getting the stamp up and running, I guess. I did about 10 other program to investigate the uln2803, input buttons, and the like. I am sure this whole thing will have to be recoded when the mute circuit goes in as well as the input selector and shift register. BTW the relays engage resistors that are 8k, 4k, 2k, 1k, 500R, 250R, 128R and 64R with the latter being on the LSB and the 8K being on MSB. The resistors are on the input of the volume control and switch NC to ground and NO to output line.
Any suggestions????
Chemania
DIRS = %0011111111
Anyway, when you get some pics, post 'em...Trust me, I know all about rough-looking prototypes...·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--==<{Chris}>==--
Does the DIRS statement work when you have named the pins? my newest version of the proggy names the pins for better readability. When I started coding the mute circuit I got lost so I had to rehash some things.
Chemania
Jim
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--==<{Chris}>==--
Can't you specify DIRS anywhere in the program, or is it strictly limited to an initial setting.
Jim
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--==<{Chris}>==--
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--==<{Chris}>==--
Chemania
It seems I almost always end up getting things backwards when I flip a circuit board over. I believe that is what I did when I wired the header. If I rewire the header then my naming system goes down the tube. I always wanted to buy that 8 channel adc for the C64 but could never afford it. Do you remember that one? I did use the tape drive power on the vic20 to switch a relay once though!
Chemania
IF NOT muted THEN
IF Vol_Up AND volume < 255 THEN volume = volume + 1
IF Vol_Dn AND volume > 0 THEN volume = volume - 1
ELSE
IF Vol_Up AND mute_vol < 255 THEN mute_vol = mute_vol + 1
IF Vol_Dn AND mute_vol > 0 THEN mute_vol = mute_vol - 1
ENDIF
Which does not work......actually it acts as if the else statement is not there, but
IF muted THEN
IF Vol_Up AND mute_vol < 255 THEN mute_vol = mute_vol + 1
IF Vol_Dn AND mute_vol > 0 THEN mute_vol = mute_vol - 1
ELSE
IF Vol_Up AND volume < 255 THEN volume = volume + 1
IF Vol_Dn AND volume > 0 THEN volume = volume - 1
ENDIF
works perfectly. What am I missing about how the IF...THEN....ELSE statement works? I checked the stamp manual and they don't even mention the ELSE construct nor is ELSE listed as a reserve word in the reserve word list (BS2P).
BTW this bit of code is for a section of the volume control that allows me to mute the thing and then change the volume while muted. Good for if someone walks in the room while you are cranking it.
Chemania
Actually neither one should really work properly. The compiler should really give you an error on your syntax. The IF / THEN on one line only allows an address (label) as an argument:
IF NOT muted THEN ChangeVol
ChangeVol:
In order to have an command you have to use a multiline form. So, you syntax would be:
Also, note the indentation. While not syntactically required, indenting the objects of your if makes them much easier to read.
Jim
I don't remember the 8-Channel ADC for the 64...I think probably because back then I was making my own boards, although I don't think I ever did a multi-channel ADC for the 64.
Tape Drives...Now I'm feeling Nastalgic!· Commodore really simplified Tape Drives for computers back then.· No having to run 3 wires between each unit.· Just one plug.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--==<{Chris}>==--
Chris - have you done anything with a C64 lately? I pulled one out of moth balls a couple of years ago. I thought it loaded slow in the mid 80's it seems like it takes a month and a half now! Still fun to play loadrunner on though...
Interesting discovery about the NOT operator. I would certainly consider it a bug in PBASIC.
IF muted THEN
IF (muted = 1) THEN
IF NOT (muted = 1) THEN
all work correctly. However
IF NOT muted THEN
IF NOT (muted) THEN
do not work correctly.
My cut would be that if you are going to allow a boolean expression as a condition, than the NOT operator should work in conjunction with it. The help text states:
Jim
NOT_muted=0
muted=1
So the you say
if NOT_muted then
this
this
Else
Of course you would also have to set up an input for your muted switch in the program (probably already have)
Shawn
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Shawn Lowe
Remember - No matter where you go
There you are.
So that when the portion of my program that reads the state of the Mute button sets Muted (VAR bit) to true (1) then NOTing Muted will still be true because NOTing %0000000000000001 still give a nonzero number. I don't see any other way to set a flag in one section of the program and NOT it in another section unless I use another if then construct to do a synthetic NOT.
Are you saying that in order to do a true logical not then I should have an expression (muted=1) or (muted=0) insteading of letting the stamp set the value of the expression?
Chemania
What you are describing is the actions of the inverse operator (~). If the NOT were to be implemented as you describe I fail to see how it would work at all. But it does work properly in the instance of "IF NOT (muted=1)", since "muted=1" (when muted is in fact equal to 1) returns a logical "1". NOT then logically negates that yielding a "0".
Reread the quoted text from the help docs that I posted. They specifically state that NOT "returns the logical NOT of an expression". A logical NOT in the case of a single bit argument happens to also be the same as an invert. But it is not the same on multi-bit argument.
Now it is possible that what you describe is what happens internally, but if that is the case than the usage of NOT when applied to a single variable as an conditional expression is inconstantly applied in comparison to a multi argument conditional expression.
I think that either they have a documentation problem with the description of NOT, or an implementation bug. Not sure which, hopefully somebody from Parallax can comment on this. From a programming perspective, having NOT perform a true and proper logical NOT on the results of the expression would certainly be more intuitive as well as more consistent with other languages.
Jim
Many thanks for straightening me out,
Chemania
Jim
IF (muted = Yes) THEN ....
No ambiguity. No tricking operators. A simple set of constant definitions (for the states of Yes or No that work with muted) will make the program easier to write, read, and maintain.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA