|
Exitlights posted:The next step is to figure out how to switch this with a transistor or relay using a microcontroller. I'm concerned about flyback voltage, which looks like it's going to be a problem with my starter. I think in most cars you'd operate the starter motor via some sort of chunky relay, because it draws incredible current. However, you'd operate that relay with a transistor as per your diagram, if what you're doing is what I think you're doing (I was confused by the placement of the uC in the diagram, where it's powered from, etc.) I think the location of the diode is fine for handling the inductive load too. Edit: Oh, and if the signal's coming straight out an MCU/digital logic you'll want a resistor before the base of the transistor so as to not stuff too much current into its gaping maw. Charles Ford fucked around with this message at 21:16 on Oct 6, 2010 |
# ? Oct 6, 2010 21:10 |
|
|
# ? May 30, 2024 07:22 |
|
Charles Ford posted:I think in most cars you'd operate the starter motor via some sort of chunky relay, because it draws incredible current. However, you'd operate that relay with a transistor as per your diagram, if what you're doing is what I think you're doing (I was confused by the placement of the uC in the diagram, where it's powered from, etc.) Yeah, that makes a lot of sense... it would be odd if I had access to two wires that powered the starter directly that are running into the wireless module. Sorry for the vagueness about the uC, that's just a digital control line (+) and ground (-), but the uC will just be powered by the car's battery. As far as the resistor goes, if I pull the + line coming out of the MCU high, will my MCU encounter any resistance in the transistor? Or is that why I need the resistor?
|
# ? Oct 7, 2010 01:29 |
Exitlights posted:Yeah, that makes a lot of sense... it would be odd if I had access to two wires that powered the starter directly that are running into the wireless module. Sorry for the vagueness about the uC, that's just a digital control line (+) and ground (-), but the uC will just be powered by the car's battery. Ib on a transistor is going to be somewhere in the ballpark of (Vin-0.7)/Rb - the Vbe relationship is similar to that of a diode, when forward biased there is a certain Vbe voltage, I usually use .7 to simplify the calculations. There are some physical limitations in place, without a resistor you run the chance of drawing a shitton of current. You want enough Ib to drive the transistor into saturation fast, but not too much to hurt your microcontroller. Assuming its a 5V micro, you may want something like: 10 mA = (5-.7) / Rb, Rb = 5-.7 / 10ma = 430 ohm. A 470 ohm resistor is common and should be in the acceptable range.
|
|
# ? Oct 7, 2010 03:51 |
|
Any recommendations on a 20-30 amp diode for my application of preventing back feeding into a power supply?
|
# ? Oct 7, 2010 07:11 |
|
Exitlights posted:Yeah, that makes a lot of sense... it would be odd if I had access to two wires that powered the starter directly that are running into the wireless module. Sorry for the vagueness about the uC, that's just a digital control line (+) and ground (-), but the uC will just be powered by the car's battery. On that note of "how much power will a transistor's base draw unattended", I got a plain TO-92 2N2222 transistor to set fire to a potentiometer through the base current alone. I added a 1k resistor after that.
|
# ? Oct 7, 2010 14:26 |
|
Does anyone have any good places online to purchase wires with female terminals pre-crimped onto an end? Something where I could take like 10 of them and snap them into a plastic 2x5 connector to hook onto a pc board header. I've found these: http://www.pololu.com/catalog/category/71 But they're 2.54mm pitch and I'm looking for 2.0mm
|
# ? Oct 7, 2010 20:30 |
|
OK, tested my circuit out today, and had a bit of a problem. First, here's the circuit I put together: Transistor is a 2N4401, FWIW. The way my car works is that + and - on the door lock/unlock/car start, when connected, activates whichever system it's for. So, connect + and - to each other for the door lock, and the doors lock. So, I hooked up the + and - terminals on the car's door lock terminals to the + and - on the door lock part of my circuit, and connected the + and - on the uC part of my circuit to the 5v and ground on my MCU. This lit the transistor on fire (in particular, the emitter terminal looks like it was what lit on fire, since it's missing a leg now...). What happened? I've got a couple guesses, but some insight would be great. I'm thinking that the 5v on the 2N4401 wasn't enough to *fully* close the collector-emitter connection, so the remaining resistance between the two was enough to light the transistor on fire. Another alternative is that I don't really understand transistors too thoroughly, and it's impossible to get rid of enough resistance to channel all the current my car needs to control these systems through a pretty cheap transistor. Or some third thing that I didn't consider. So, I need a new transistor, or need to switch to a relay (may need a transistor to switch the relay, ugh). Which is it? Edit: here's a thought, since I'm worried about the amount of current my MCU is putting out to control the collector-emitter path: should I use a Darlington transistor instead? Edit2: looking at the specs for the transistor I got, I really shouldn't have been surprised when it melted, collector current is rated at 600mA, and I'm trying to run an air compressor off of that. I'm thinking the TIP120 should be sufficient for what I need: http://www.fairchildsemi.com/ds/TI/TIP120.pdf Exitlights fucked around with this message at 20:48 on Oct 10, 2010 |
# ? Oct 10, 2010 20:19 |
|
Keebler posted:Does anyone have any good places online to purchase wires with female terminals pre-crimped onto an end? Something where I could take like 10 of them and snap them into a plastic 2x5 connector to hook onto a pc board header.
|
# ? Oct 10, 2010 21:16 |
|
randyest posted:I don't know about pre-crimped wires, but I got a bunch of terminals and a crimper pretty cheaply from Digikey.com . The stuff was cheaper there than my local store (U-do-it). Can you please provide item numbers. Whenever I look for crimping stuff I find ridiculously expensive Tyco/Amp tools that cost $800 to perform the most simple function.
|
# ? Oct 11, 2010 01:48 |
|
That's the reason I was looking for pre-crimped wires too, all the crimping tools that I could find were too expensive considering the amount of use I expected to get out of them.
|
# ? Oct 11, 2010 02:04 |
|
Look up crimpers at http://www.dealextreme.com/ You can get some cheap as hell ones that'll last you a couple weeks, which is all you need. Free shipping, too.
|
# ? Oct 11, 2010 02:25 |
|
Uh... lil' help >_> So I was messing around building a silly 60 second binary LED timer to get my feet wet programming MCUs. I'm using a PIC12F509 to light up some leds. Simple project. Well, I found out the hard way that I should read the datasheet more thoroughly when my LED on GP3 wasn't working since it turns out that pin is input only. But now I have a more complicated issue. The pin on GP2 isn't working either and according to the datasheet that IS a regular, bidirectional IO pin. I've checked the led by lighting it up with my tester and it works. All the connections seem fine. Here's the schematic from the whole project. I know now that the GP3 LED is wrong. Also, I realize I'm probably doing something stupid and fully admit that I'm an ignorant newbie that should read more before doing this stuff, but I can't help it. I need to get my hands dirty to learn So please, do enlighten me as to whatever else I'm doing wrong: Here's the simplified TEST code. I'm using the CCS compiler and libraries. This code brings me no joy (reads: no light from the LED): code:
LINK Hope thats enough. Thank you for your time in advance =)
|
# ? Oct 11, 2010 15:18 |
|
My only experience is with AVRs, not PICs but I believe you probably need to put GP2 into output mode:quote:On Reset, all I/O ports are defined as input (inputs are at high-impedance) since the I/O control registers are all set. I think you need to do this through the TRISGPIO register.
|
# ? Oct 11, 2010 15:51 |
|
Keep in mind that the other LEDs DO light up (even though they're not in the simplified code version). I think the output_high() function does the setup automatically. EDIT: Just in case, I changed the test code to use another pin and it does indeed light up. No settings required. So yeah, what the hell is up with the GP2 pin? Faulty chip? CptAJ fucked around with this message at 17:04 on Oct 11, 2010 |
# ? Oct 11, 2010 16:25 |
|
CptAJ posted:Keep in mind that the other LEDs DO light up (even though they're not in the simplified code version). I think the output_high() function does the setup automatically. It'd still be worth either investigating the C startup code your compiler is using or looking at the source to the output_* functions, who knows what they're doing. Perhaps before it calls your main it configures your chip with some outputs out and some in for some demo dev board. Do that or try explicitly setting the output anyway before deciding it's a dud chip or anything.
|
# ? Oct 11, 2010 17:11 |
|
CptAJ posted:Keep in mind that the other LEDs DO light up (even though they're not in the simplified code version). I think the output_high() function does the setup automatically. You should set it as a regular IO rather than as a reset, but if you do that right at the start of your code, you will no longer be able to program the device. To get around this, at the start of your code, you should set all devices as inputs and then pause for a second. After the pause, configure your outputs normally. This pause will give the programmer a chance to apply the programming voltage to MCLR and put it into programming mode. You should also disconnect that LED while programming because the programming voltage is 13V which might burn out the LED. Edit: oh wait i read that wrong. You already realized there was a problem with GP3 since it's input only. Let me get back to you about GP2. Edit: Try clearing T0CS (bit 5) of the OPTION register. datasheet posted:Note: If the T0CS bit is set to ‘1’, it will override the TRIS function on the T0CKI pin Mill Town fucked around with this message at 18:54 on Oct 11, 2010 |
# ? Oct 11, 2010 18:41 |
|
CptAJ posted:Keep in mind that the other LEDs DO light up (even though they're not in the simplified code version). I think the output_high() function does the setup automatically. If you think a function does something, it doesn't, unless it provably does. This is doubly true for setting pin I/O states. I hate the PIC libraries so bad that I end up writing almost all the setup in assembler. Before your loop, explicitly set everything the way it needs to be.
|
# ? Oct 11, 2010 19:58 |
|
Yeah I almost never use hardware-specific library functions when programming PICs in C. I don't know about your compiler, but the official Microchip compilers define variables in the processor-specific header files mapped to special function registers. I always consult the datasheets and set up the hardware as needed through those. It's a tiny bit more work but at least you know what state the hardware is in at any given point. Edit: Oh yeah I have my own question: I'm powering a robotics project with a 12V battery. It needs 3.3V for the logic and about 5-6V for servos and DC motors. To save space on the board I'm going to use the main microcontroller (a dsPIC) to control a buck converter to get the lower voltage for the motors rather than to use a dedicated IC for that. The dsPIC itself will be powered by a linear regulator, but the current draw is so low that the high voltage drop shouldn't be a big deal. The buck converter will use a PWM generator and ADC channel on the PIC and will be regulated by software. I've got the hardware designed and I don't think there are any issues with it, but what algorithm should I use to control the buck converter? I'm pretty decent at embedded programming but power control is new territory for me so I don't know where to begin with programming that. BattleMaster fucked around with this message at 22:48 on Oct 11, 2010 |
# ? Oct 11, 2010 22:31 |
|
Aaaand Mill Town takes the cake. Thanks dude. That did it. Had to learn a bit of assembly there to set it up Thanks for the advice guys. I'll keep it in mind next time =)
|
# ? Oct 11, 2010 23:01 |
|
BattleMaster posted:I've got the hardware designed and I don't think there are any issues with it, but what algorithm should I use to control the buck converter? I'm pretty decent at embedded programming but power control is new territory for me so I don't know where to begin with programming that. Go to http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2524¶m=en539690 and sort the device type to the appropriate dsPic family. There are a few different DC/DC code examples for different feedback types. That should get you started.
|
# ? Oct 12, 2010 01:46 |
|
TacoHavoc posted:Go to http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2524¶m=en539690 and sort the device type to the appropriate dsPic family. There are a few different DC/DC code examples for different feedback types. That should get you started. You know what the awesome thing is? I knew full well about the application notes library that Microchip has and I knew full well that they push the dsPIC for power control but for some reason I never bothered to check it out for help with this. drat I'm stupid. Thanks for jogging my memory!
|
# ? Oct 12, 2010 01:52 |
|
CptAJ posted:Aaaand Mill Town takes the cake. Thanks dude. That did it. Had to learn a bit of assembly there to set it up No problem. For future reference you should be able to twiddle register bits from within C without using any assembly, with the bitwise AND and bitwise OR operators: OPTION = OPTION & 0x11011111; This will turn off the 5th bit and leave every other bit unchanged. You can do the opposite (set a bit to 1) like so: OPTION = OPTION | 0x00100000; Extra fun trick: You can toggle a bit to the opposite of its previous state with ^, the XOR operator. Let's say you want to switch the output on GP0 to the opposite of its previous value, you would do: GPIO = GPIO ^ 0x00000001 For explanation as to why this all works, see here: http://www.cprogramming.com/tutorial/bitwise_operators.html
|
# ? Oct 12, 2010 04:42 |
|
Exitlights posted:OK, tested my circuit out today, and had a bit of a problem. First, here's the circuit I put together: Since no one has addressed this yet - yeah, your LED lit up like a candle because your solenoid looks just like a short under DC conditions (it is a wire after all). So you were pretty much shorting your battery to ground through the transistor. I'd get a bigger transistor (or better yet, a MOSFET) and put a small series resistance in the current path to prevent shorting under steady state.
|
# ? Oct 12, 2010 04:46 |
|
Mill Town posted:No problem. For future reference you should be able to twiddle register bits from within C without using any assembly, with the bitwise AND and bitwise OR operators: The bonus is that the C compilers are smart enough to turn those into the appropriate BCF, BSF, and BTG instructions rather than using a MOVLF and ANDWF/IORWF/XORWF pair. And of course I don't know about non-Microchip compilers but the Microchip headers define bitwise structures that let you do the same things without having to remember bitmasks. Be sure to look into that, maybe yours will let you access bits like that, too.
|
# ? Oct 12, 2010 05:07 |
|
Mill Town posted:No problem. For future reference you should be able to twiddle register bits from within C without using any assembly, with the bitwise AND and bitwise OR operators: Yeah, I'm familiar with bitwise operations. I just didn't know how to get to the register from C so I just looked up the asm instructions since it was kinda simple. I didn't see OPTION defined anywhere.
|
# ? Oct 12, 2010 05:50 |
SnoPuppy posted:Since no one has addressed this yet - yeah, your LED lit up like a candle because your solenoid looks just like a short under DC conditions (it is a wire after all).
|
|
# ? Oct 12, 2010 06:02 |
|
CptAJ posted:Yeah, I'm familiar with bitwise operations. I just didn't know how to get to the register from C so I just looked up the asm instructions since it was kinda simple. I didn't see OPTION defined anywhere. It should be defined in 12f509.h although it may be called something else.
|
# ? Oct 12, 2010 06:44 |
|
Scarboy posted:Can you please provide item numbers. Whenever I look for crimping stuff I find ridiculously expensive Tyco/Amp tools that cost $800 to perform the most simple function. I have a question too, which I sort of hit on a few pages back. If I wanted to convert a 5V 500Hz PWM to a 5V-12V output 250mA max (I also have a 12V line), how would I achieve this goal. I thought I'd be able to do it like a switching power supply with a logic-level N-channel MOSFET, an inductor, capacitor and a diode, but when applied to my load the results are the same as without the inductor (except with bigger voltage spikes on the PWM pulse edges). I keep thinking I'm going about this all wrong because it seems like something simple enough to do, convert the duty cycle directly to a proportional voltage.
|
# ? Oct 12, 2010 19:40 |
|
Anyone got a link to a good writeup on PIC data communications? I want to try out some pic-to-pic communication excercises but I can't find the right documentation. I see a lot of talk about USART modules for RS232 serial communication but... can't the regular I/O pins on most of these MCUs be used for data transfer and even serial communications?
|
# ? Oct 12, 2010 22:30 |
|
Yes you can program a serial module in software but the UART modules do that for you, greatly simplifying the amount of work you have to do (down to basically nothing). Just read the datasheet of whatever PIC you're using, it's usually pretty easy to get it start working. If you run into a problem 90% of the time it's because you set up the protocol wrong (ie not 9800-8-n-1). I recommend getting a USB breakout board for early testing from PC to PIC, like http://www.sparkfun.com/commerce/product_info.php?products_id=718 CapnBry posted:I have a question too, which I sort of hit on a few pages back. If I wanted to convert a 5V 500Hz PWM to a 5V-12V output 250mA max (I also have a 12V line), how would I achieve this goal. I thought I'd be able to do it like a switching power supply with a logic-level N-channel MOSFET, an inductor, capacitor and a diode, but when applied to my load the results are the same as without the inductor (except with bigger voltage spikes on the PWM pulse edges). I keep thinking I'm going about this all wrong because it seems like something simple enough to do, convert the duty cycle directly to a proportional voltage.
|
# ? Oct 12, 2010 23:02 |
|
CapnBry posted:I have a question too, which I sort of hit on a few pages back. If I wanted to convert a 5V 500Hz PWM to a 5V-12V output 250mA max (I also have a 12V line), how would I achieve this goal. I thought I'd be able to do it like a switching power supply with a logic-level N-channel MOSFET, an inductor, capacitor and a diode, but when applied to my load the results are the same as without the inductor (except with bigger voltage spikes on the PWM pulse edges). I keep thinking I'm going about this all wrong because it seems like something simple enough to do, convert the duty cycle directly to a proportional voltage. You should just be able to do it passively - use a diode and an LC filter to smooth the output (or no diode, but that puts more requirements on the filter). 5V 500 Hz and 250 mA is going to be tough - you will need big inductors/caps in the LC filter to smooth out the voltage (like mH and mF). There is a reason why most switchers operate in the 100s of kHz to MHz range. How fast do you need to respond to duty cycle changes? And how much resolution do you need?
|
# ? Oct 12, 2010 23:43 |
|
Zo posted:I recommend getting a USB breakout board for early testing from PC to PIC, like http://www.sparkfun.com/commerce/product_info.php?products_id=718 I'd also recommend the pure simulator in MP-LAB. It freaks out a lot, and doesn't support a lot of complex modules like the PIC USB stuff (which I use regularly) but it does simulate RS232 (reading to/from files) and supports simulated input and logic analyzer display for I/O pins, meaning you can test your bit-banging code entirely in the PC before trying it out in the real world. I've done this a number of times with lots of success, it's extremely handy (most recently to debug some PWM assembler not starting up properly)
|
# ? Oct 13, 2010 00:49 |
|
Zo posted:I recommend getting a USB breakout board for early testing from PC to PIC, like http://www.sparkfun.com/commerce/product_info.php?products_id=718 If you feel like you're serious enough about working with PICs, consider getting an ICD3 for exactly that reason. I'm a big fan of breakpoints and watch variables to make sure stuff gets executed properly.
|
# ? Oct 13, 2010 02:12 |
|
Scarboy posted:Can you please provide item numbers. Whenever I look for crimping stuff I find ridiculously expensive Tyco/Amp tools that cost $800 to perform the most simple function.
|
# ? Oct 13, 2010 03:18 |
|
Thanks for the advice. I haven't really gotten into debuggers yet. Maybe when I move to more complicated projects, but right now it hasn't been that much of a necessity. My code is pretty simple. So, back to bit banging. Its much easier finding info now that I know the name of what I'm looking for This is great. So... how about PWM, can I do that with software too?
|
# ? Oct 13, 2010 19:14 |
|
SnoPuppy posted:You should just be able to do it passively - use a diode and an LC filter to smooth the output (or no diode, but that puts more requirements on the filter).
|
# ? Oct 13, 2010 19:31 |
|
CptAJ posted:This is great. So... how about PWM, can I do that with software too? That's how I do it. I made a board to make the screen go up and down in my Mazda RX-8's OEM satnav hood - I got it with all the electronics missing, except the buttons and motor. I made a USB interface to these using a PIC, and the PIC uses PWM out of three inputs to control the brightness of the LEDs for each button (independently, so you could have open throb or whatever) as well as the brightness of the LCD backlight LED. The PIC has a PWM module but instead I just used a timer to generate a timebase. When the interrupt appears, I decrement a counter. If it hits 0, I toggle the state, and load the amount of time to keep the new state into the counter (the amount of time 'on' is the opposite of the amount of time 'off'). Works perfectly
|
# ? Oct 13, 2010 19:36 |
|
I haven't done any thing like this ever before. My eventual aim is to make some solar powered gear for camping. Aiming to run a 5w CFL for a few hours at night and provide LED strip lighting for in the tent. What should I be looking at? EDIT: Basically this http://www.jaycar.com.au/productView.asp?ID=MP4552 but built from scratch. Gorfob fucked around with this message at 09:23 on Oct 14, 2010 |
# ? Oct 14, 2010 09:20 |
|
I have a quick question maybe somebody knows... I have a grinder tool that I want to clock the RPMs of, which is 35,000 or so. I have a multimeter with a frequency counter function that goes to 10 MHz, and have a photocell cut from an automatic dusk-to-dawn light fixture. The multimeter needs .8V to trip, and the photocell drops in resistance, from a couple thousand ohms to a hundred or so. What I am wondering is if I can just run the photocell in series (or parallel) with a 1.5V battery, to the frequency counter? The multimeter's internal voltmeter resistance is 7.5Mohms, but it doesn't say what the figure is for the frequency function.... ~
|
# ? Oct 14, 2010 21:17 |
|
|
# ? May 30, 2024 07:22 |
|
If it requires a voltage to trip, then the multimeter should be using the voltmeter function to count. So I just got given a big bag of LEDs that are "burnt out." What's a fun project that uses about 100 UV LEDs?
|
# ? Oct 15, 2010 03:41 |