Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
BattleMaster
Aug 14, 2000

Slanderer posted:

I did a quick search for pencil sharpener motors---was it something like this?

http://en.wikipedia.org/wiki/Shaded-pole_motor

Not sure what you're describing w/o a picture, though.

That's actually exactly what it is. Thanks!

Adbot
ADBOT LOVES YOU

Slanderer
May 6, 2007
Does anyone here with embedded programming knowledge know the best way to write C code that has deterministic timing?

From what I've heard in passing and inferred myself, it would seem easy to write assembly routines and padding different branches with delays (either NOPs or delay loops using an instruction like branch if not equal (to some delay)) so the section of code takes the same amount of time no matter which branches are taken, and this could be extended for more complex constructs.

But what's the proper way to do this with a high level language? Do I just write the code, and then run it through a simulator/debugger and see how many instructions each branch within the section of code takes? Is there some more professional way of doing this? Also, how can I know for sure that my compiler won't change how that part of the code is compiled, even if they're unrelated (because I assume that the compiler is dumb)?

ante
Apr 9, 2005

SUNSHINE AND RAINBOWS
When doing anything with that kind of precision, I would definitely switch to assembly. If you use inline assembly in your c code, be very very careful with functions and the stack.

BattleMaster
Aug 14, 2000

Yeah, gonna say that if you need that kind of precision you don't use C. Well if you can read the disassembly listing and you have a good feel for what statements turn into what instructions I guess you could pull it off but I bet it would be too much effort compared to just using assembly.

Pizer
Aug 8, 2004
If your clock was fast enough and it wasn't important to run the code as fast as possible couldn't you start a timer before the branches and have them return to some code that waits until the timer hits a specific value?

Actually I suppose it wouldn't be very inefficient if you made the timer just slightly longer than the longest path.

Zo
Feb 22, 2005

LIKE A FOX

Slanderer posted:

Does anyone here with embedded programming knowledge know the best way to write C code that has deterministic timing?

From what I've heard in passing and inferred myself, it would seem easy to write assembly routines and padding different branches with delays (either NOPs or delay loops using an instruction like branch if not equal (to some delay)) so the section of code takes the same amount of time no matter which branches are taken, and this could be extended for more complex constructs.

But what's the proper way to do this with a high level language? Do I just write the code, and then run it through a simulator/debugger and see how many instructions each branch within the section of code takes? Is there some more professional way of doing this? Also, how can I know for sure that my compiler won't change how that part of the code is compiled, even if they're unrelated (because I assume that the compiler is dumb)?
Depends on how accurate you need it, c can work. In the automotives industry they get around this by, as was mentioned, having a fast clock and using only one ISR essentially, that being the clock peripheral, .

You just tick a clock variable every time the clock ISR hits and run everything else based off of that. So certain routines can go every 5 milliseconds, other can go every 10 milliseconds etc. This way if even a particular routine takes longer than a single clock cycle (or even many clock cycles), because the clock ISR has the highest priority your overall timing won't slip.

By much, anyways.

Slanderer
May 6, 2007

Zo posted:

Depends on how accurate you need it, c can work. In the automotives industry they get around this by, as was mentioned, having a fast clock and using only one ISR essentially, that being the clock peripheral, .

You just tick a clock variable every time the clock ISR hits and run everything else based off of that. So certain routines can go every 5 milliseconds, other can go every 10 milliseconds etc. This way if even a particular routine takes longer than a single clock cycle (or even many clock cycles), because the clock ISR has the highest priority your overall timing won't slip.

By much, anyways.

That's the way I'm doing things currently. The microcontroller I'm currently working with has a total of 7 timer/counters. Each of these as either 2 or 4 compare channels (or capture channels, for input), each of which can trigger an interrupt, as well as normal overflow interrupts. And if I want to increase the timer resolution from 16 bits to 32 bits, I can use a feature called the "Event System", which routes triggers/data/whatever between individual peripherals w/o CPU intervention, to chain two timers together into a 32 bit timer. It can do a gently caress ton more, too.

Frankly, I'm mostly interested in doing stuff the "old" way because I'm sorta spoiled by the scope of the peripherals I'm working with.

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

Slanderer posted:

Frankly, I'm mostly interested in doing stuff the "old" way because I'm sorta spoiled by the scope of the peripherals I'm working with.

Microcontrollers have had timer peripherals for a looong time. For example, Intel's 8051, released in 1980, has two 16-bit counters with interrupts. I wouldn't consider it a modern convenience in the same realm as an integrated CAN controller or similar.

BattleMaster
Aug 14, 2000

The Intel 8080 and Zilog Z80 both had official timer chips in their peripheral collection so computers have pretty much had access to timers since they've been small enough to use in embedded applications. If you want to do it the hard way then you're just going to have to get used to reading disassembly listings :)

-

So I discovered that high-side MOSFETs in a bridge need to be driven with a higher voltage than the load. Which makes sense now that I think about it but was confusing the hell out of me when my first attempt at an H-bridge was screwing up.

So I built a charge pump with a 555 timer (:neckbeard:) and everything's cool. Only thing is, while it works I don't know how to select the frequency or capacitor values or anything like that. Searching for charge pumps seems to only find articles on how to use ASIC charge pumnps. Anyone have any resources on designing charge pumps?

ANIME AKBAR
Jan 25, 2007

afu~

taqueso posted:

Microcontrollers have had timer peripherals for a looong time. For example, Intel's 8051, released in 1980, has two 16-bit counters with interrupts. I wouldn't consider it a modern convenience in the same realm as an integrated CAN controller or similar.

Having a basic timer is one thing. But the MCU he's talking about has things like direct timing of the DMA controller, several compare and capture registers, triggered control of other peripherals, etc. For realtime applications those hardwired event systems can eliminate the need for several interrupt routines in software.

BattleMaster posted:

So I discovered that high-side MOSFETs in a bridge need to be driven with a higher voltage than the load. Which makes sense now that I think about it but was confusing the hell out of me when my first attempt at an H-bridge was screwing up.

So I built a charge pump with a 555 timer (:neckbeard:) and everything's cool. Only thing is, while it works I don't know how to select the frequency or capacitor values or anything like that. Searching for charge pumps seems to only find articles on how to use ASIC charge pumnps. Anyone have any resources on designing charge pumps?
Just use a bootstrapping high side driver like everyone else does. Works fine, so long as you aren't driving the FET at 100% duty cycle. International rectifier makes good ones, like the IR2110.

Captain von Trapp
Jan 23, 2006

I don't like it, and I'm sorry I ever had anything to do with it.
Possibly stupid question about the Arduino: the circuit can only push something like 40mA from each output pin, so if you need more you have to use the pins to switch current from the power supply through a transistor or something. But what's the limit on the current you can safely draw from the Vin pin, assuming your DC power supply is otherwise up to the task?

sixide
Oct 25, 2004
200mA, though certainly not for any significant length of time.

Whompy
Apr 21, 2002
I don't suppose anyone here has any familiarity with some manner of circuit/sensor designed to measure salinity?

I have a couple of possible sensors in mind (e.g. this) but am not sure I'll be able to discern it's mode of operation.

I suppose I should mention that it's for a fishtank (my own) and that finding an off-the-shelf salinity sensor is neigh-on-impossible under a reasonable budget.

Any ideas?

SnoPuppy
Jun 15, 2005

Whompy posted:

I don't suppose anyone here has any familiarity with some manner of circuit/sensor designed to measure salinity?

I have a couple of possible sensors in mind (e.g. this) but am not sure I'll be able to discern it's mode of operation.

I suppose I should mention that it's for a fishtank (my own) and that finding an off-the-shelf salinity sensor is neigh-on-impossible under a reasonable budget.

Any ideas?

I would guess that salinity has an inverse relationship to resistance, so you could measure the resistance between two probes of a fixed distance and correlate that to salinity. It would require calibration, and the probes will corrode quickly they're copper.

BattleMaster
Aug 14, 2000

ANIME AKBAR posted:


Just use a bootstrapping high side driver like everyone else does. Works fine, so long as you aren't driving the FET at 100% duty cycle. International rectifier makes good ones, like the IR2110.

Yeah that's probably the best solution. I just wanted to rig up something with parts I already had. There isn't enough stuff I want to buy to justify the shipping from Digikey so I'll see if one of the hobby shops here has a high-side driver.

Slanderer
May 6, 2007

SnoPuppy posted:

I would guess that salinity has an inverse relationship to resistance, so you could measure the resistance between two probes of a fixed distance and correlate that to salinity. It would require calibration, and the probes will corrode quickly they're copper.

I'm no chemist, but it should also be affected by the amounts of potassium, calcium, and crap like that in the water.

Calibration is probably going to be annoying with a couple reference solutions (some tap water has a LOT of sodium in it)

ANIME AKBAR
Jan 25, 2007

afu~

sixide posted:

200mA, though certainly not for any significant length of time.

I routinely run ~250ma through the 5V regulator on my arduino for hours at a time, from a 12V input. Gets drat hot, but hasn't broken yet. Keep in mind the max current tolerated by the regulator will depend on the input voltage (more input voltage means more heat and less max current).

sixide
Oct 25, 2004
That's regulator current, and given typical linear regulator efficiencies not all of that is making it to the Vcc pin on the MCU. The 328 is rated to 200mA as an absolute maximum.

BattleMaster
Aug 14, 2000

Slanderer posted:

I'm no chemist, but it should also be affected by the amounts of potassium, calcium, and crap like that in the water.

Calibration is probably going to be annoying with a couple reference solutions (some tap water has a LOT of sodium in it)

Yeah, any ions, not just sodium ones, would act as charge carriers and would contribute to a lower resistance.

csammis
Aug 26, 2003

Mental Institution
The following assumes that Whompy has a saltwater fishtank:

1) Calibration would be easy since RO/DI water should have a zero or near-zero total dissolved solids and be pretty deionized.

2) I don't think it's a good idea to put bare copper in the water (copper kills marine invertebrates).

3) Would another metal be sufficient for measuring resistance between two probes? Most metal motor axles for powerheads and such are titanium and even that corrodes eventually but it takes a lot longer.

4) I'm not sure what Whompy's setup is like or why he's testing for salinity in the first place but would specific gravity be a possible alternative measurement? I have zero idea if that can be measured electronically. I've only seen it measured optically with a refractometer and via buoyancy with those goofy swing-arm things.

ANIME AKBAR
Jan 25, 2007

afu~

sixide posted:

That's regulator current, and given typical linear regulator efficiencies not all of that is making it to the Vcc pin on the MCU. The 328 is rated to 200mA as an absolute maximum.

Oh, I thought he was asking for the regulator limit. Yeah, for most microcontrollers there is a max current per pin, but there is also usually a maximum current per I/O bank which puts an additional limit on total current. 200ma sounds right.

BattleMaster
Aug 14, 2000

csammis posted:

3) Would another metal be sufficient for measuring resistance between two probes? Most metal motor axles for powerheads and such are titanium and even that corrodes eventually but it takes a lot longer.

One of my friends was doing a project that involved salinity measurement and I think I recall platinum being used because it doesn't corrode. I know for sure that they use it when doing electrolysis of water for that reason.

Speaking of which, I think I recall my friend having to use AC across the electrodes or else it actually would begin to electrolyze water.

BattleMaster fucked around with this message at 18:32 on May 31, 2011

SnoPuppy
Jun 15, 2005

csammis posted:

The following assumes that Whompy has a saltwater fishtank:

1) Calibration would be easy since RO/DI water should have a zero or near-zero total dissolved solids and be pretty deionized.

2) I don't think it's a good idea to put bare copper in the water (copper kills marine invertebrates).

3) Would another metal be sufficient for measuring resistance between two probes? Most metal motor axles for powerheads and such are titanium and even that corrodes eventually but it takes a lot longer.

4) I'm not sure what Whompy's setup is like or why he's testing for salinity in the first place but would specific gravity be a possible alternative measurement? I have zero idea if that can be measured electronically. I've only seen it measured optically with a refractometer and via buoyancy with those goofy swing-arm things.

Measuring conductivity would be the easiest. Density measurements would require ultrasonics or a mechanical float gauge.

Ideally, you would use gold or platinum plated electrodes, since those do not corrode like copper does. Honestly, I think just buying a sensor would be the easiest - the electronics won't be difficult, but constructing a robust probe head will be.

Now, if this is just a quick measure of the water, and then you remove and clean the probe, you could probably get away with a PCB that has an ENIG finish. Just make sure you wash the PCB before you put it in the tank, and definitely don't keep it submerged for any length of time.

Slanderer
May 6, 2007
A quick search revealed that all these salinity monitors are encapsulated things. Now, that's probably just because they threw the electronics in their, but is there any chance they use a more complicated (and selective) electrode like pH meters do?

ie,

http://en.wikipedia.org/wiki/Glass_electrode

EDIT: Apparently I'm not talking out of my rear end:

https://www.sciencelab.com/page/S/PVAR/50-FC300B

Slanderer fucked around with this message at 18:57 on May 31, 2011

jacteh
Jul 10, 2007
.

SnoPuppy posted:

Measuring conductivity would be the easiest. Density measurements would require ultrasonics or a mechanical float gauge.

Pg = (rho)*g*h

Is it practical to measure height and static pressure of a column of saltwater? Or if you had an overflow setup to control height of the water column, all you need to measure is pressure.

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

Anyone know of a USB-B jack with integrated LED, like some RJ45 jacks?

Slanderer
May 6, 2007

taqueso posted:

Anyone know of a USB-B jack with integrated LED, like some RJ45 jacks?

The closest I could find were USB + RJ45 (with LED) combinations.

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

Slanderer posted:

The closest I could find were USB + RJ45 (with LED) combinations.

Ya, I looked for a few hours and couldn't find even a hint of one.

BattleMaster
Aug 14, 2000

taqueso posted:

Anyone know of a USB-B jack with integrated LED, like some RJ45 jacks?

I don't think that's in the spec.

doug fuckey
Jun 7, 2007

hella greenbacks
What up thread. I posted this question in ML but got no answers; I'm not very electronics savvy but I've learned quick and decided to jump right in and try a DIY guitar stomp-box. Here's what I asked in ML:

big business sloth posted:

So I've decided to build my own distortion box via an old walkman tape player, after seeing all these videos/pics about it. I figured it'd be simple, slap a jack onto where the tape head goes and one on where the audio out/speakers go, and that'd be that. However I know nothing about electronics and have become confused by what I discovered when I opened up my tape player. I was following the instructions on http://brokenpants.com/?page_id=211 but what I've got appears to be different. I'd google this sort of thing but my lack of understanding and terminology makes it difficult. My problem is:

-I figured the tape head would be connected to three wires; red, white, and black. It was not. It's just two wires, a salmon colored one and a small yellow one that goes inside the salmon jacket. They eventually both disappear into the circuit board.

-What I thought was a mono cord that I split open turned out to be a two-contact one. However, this is the cord with three red black and white wires in it. My other cable, the true mono one, has just a shielded inside wire and the wire under the black jacket. So two I guess.

Could someone knowledgeable just point me in the right direction on what I've got going on here? Greatly appreciated.

edit: I guess I should mention that I'm working with a tape player/recorder, and the output would be from some on-deck speakers.

As I said, just a point in the right direction would be much appreciated.

sixide
Oct 25, 2004
I suspect you're missing a conductor on the tape head. It could be very small. The alternative is that your walkman is actually mono. Trace out where the conductors go, if it terminates at 2 places on the PCB it's probably a mono playback head. Basically it's still possible but you can't feed the signal through twice. If there's 3 terminations, there's no issue.

I don't really understand why you'd want to apply the ludicrous amount of gain needed to amplify a tape head signal up to headphones level twice.

As for the second, I don't understand what the problem is. You have both mono and stereo cables?

Also if this works out well, you should look into using one of those old line-to-cassette adapters for tape saturation. It sounds pretty awesome. Even better if you could use a tape loop and a record and playback head. Then you could saturate, delay, and add tape flutter.

doug fuckey
Jun 7, 2007

hella greenbacks
Yeah, the wires both terminate independently on the board. So it's mono then I guess?

Regarding the cables; I guess I'm just not sure how they work. Guitar cables are mono I thought, so I figured in the instructions on the blog he'd be using mono cables to get it done. But he uses cables that have three wires, (red white black) which is how my stereo cable is. So I guess he's using stereo cables? Either way, what would be the logical connection for the mono cable (er, which wire does which?).

I actually tried wiring it up once, this is how I did it:

code:
Mono Cable======-------shielded wire--------||----small yellow tapehead wire--|BOARD|
                \---outer wire--------------||-----salmon tapehead wire-------|BOARD|
                                                                              
and then

|BOARD|-------red speaker wire----||---stereo cable RED------\____________AMPLIFIER
|BOARD|-------blue speaker wire---||---stereo cable WHITE----/
I figured the black stereo cable was a ground of some kind and wired in in a logical place on on the body of the walkman. This is probably not right and I feel dumb looking back now.

Anyway, this produced no sound, obviously, but I'm sure I'm just missing some key element.

Trabisnikof
Dec 24, 2005

big business sloth posted:

Yeah, the wires both terminate independently on the board. So it's mono then I guess?

Regarding the cables; I guess I'm just not sure how they work. Guitar cables are mono I thought, so I figured in the instructions on the blog he'd be using mono cables to get it done. But he uses cables that have three wires, (red white black) which is how my stereo cable is. So I guess he's using stereo cables? Either way, what would be the logical connection for the mono cable (er, which wire does which?).

I actually tried wiring it up once, this is how I did it:

code:
Mono Cable======-------shielded wire--------||----small yellow tapehead wire--|BOARD|
                \---outer wire--------------||-----salmon tapehead wire-------|BOARD|
                                                                              
and then

|BOARD|-------red speaker wire----||---stereo cable RED------\____________AMPLIFIER
|BOARD|-------blue speaker wire---||---stereo cable WHITE----/
I figured the black stereo cable was a ground of some kind and wired in in a logical place on on the body of the walkman. This is probably not right and I feel dumb looking back now.

Anyway, this produced no sound, obviously, but I'm sure I'm just missing some key element.

He's using an XLR, or balanced mono. Which basically wires, signal-ground-inverse_signal. So if you are receiving unbalanced then just connect one of the signals up.

sixide
Oct 25, 2004

big business sloth posted:

I figured the black stereo cable was a ground of some kind and wired in in a logical place on on the body of the walkman. This is probably not right and I feel dumb looking back now.

Aren't walkmans usually plastic? Be sure you're connected to the signal ground at the output.

Also there's a possibility that I didn't think of earlier, the tape head's housing might serve as the return path. It could be electrically connected through a screw or something.

edit:
Standard 1/8" and 1/4" jacks/plugs are set up so that connections between mono and stereo will be tied together. Basically, it will approximate a sum of the left and right channels.

sixide fucked around with this message at 02:43 on Jun 3, 2011

Slanderer
May 6, 2007

sixide posted:

Aren't walkmans usually plastic? Be sure you're connected to the signal ground at the output.

Also there's a possibility that I didn't think of earlier, the tape head's housing might serve as the return path. It could be electrically connected through a screw or something.

edit:
Standard 1/8" and 1/4" jacks/plugs are set up so that connections between mono and stereo will be tied together. Basically, it will approximate a sum of the left and right channels.

You've been preempting most of the posts that I've wanted to write, but one thing--a quick search revealed that some really cheap "Walkman"s were actually only mono, although I'm not sure if that meant they mixed the two audio channels from the tape, or only read one.

Also, all the magnetic card read/write heads I've seen have always been free-hanging modules that snap into the plastic mechanism, isn't of being soldered to something (so it's further unlikely that the metal of the head is the ground return)

doug fuckey
Jun 7, 2007

hella greenbacks
Ok let me make some corrections now that I have the thing in front of me. First, there was a black wire from the board that was originally soldered to a small contact on a screw on the motor body mechanism. When the play button is pushed, something moves beneath it. I cut this to remove the motor mechanism, and also a red and black wires that I assume were sending power to the motor. These I have left free.

The black that was on the screw contact I had connected to the black from the R/W/B 1/4" jack plug.

EDIT Fuckin' got it to work! there was a power connection that needed to be fixed, probably the play button's job or some poo poo. Gonna play it in my setup right now, I would like to know what I could possibly do with the record head. Fun stuff?

Thanks for the insights anyhow.

EDIT 2: Further insights after the initial success. It actually sounds more like a fuzz pedal than a distortion pedal, and to be honest the signal is a little weak. Also, whenever there is input from the guitar, the battery button grows dimmer for a moment, and with sufficient signal it actually switches off for a second and cuts the sound. It's kind of neat but pretty annoying. Anyway I think I'll want to route the signal through the circuit a second time, but that will require some more wire, I would think.

doug fuckey fucked around with this message at 19:07 on Jun 3, 2011

Slanderer
May 6, 2007
From the Scammed! thread:

Corla Plankun
May 8, 2007

improve the lives of everyone
How do you all like to draw circuits? I was reading "Make" earlier and I am pretty impressed by their schematics. I usually just print whatever Orcad Capture shows me but I'm feeling really inadequate right now.

Only registered members can see post attachments!

Slanderer
May 6, 2007

Corla Plankun posted:

How do you all like to draw circuits? I was reading "Make" earlier and I am pretty impressed by their schematics. I usually just print whatever Orcad Capture shows me but I'm feeling really inadequate right now.



Curved lines?! That's just weird

Adbot
ADBOT LOVES YOU

Chalupa Joe
Mar 4, 2007

Slanderer posted:

Curved lines?! That's just weird

Wires going through components? That's just wrong.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply