Beginners: please read this post and this post before posting to the forum.
0 Members and 1 Guest are viewing this topic.
#define DEBUG 0#define WAIT_FOR_START 1unsigned char incomingByte = 0;unsigned long loop_count = 0;unsigned char horn = 32;unsigned char redLED = 64;unsigned char BlueLED = 128;unsigned char FireWeapon = 4;unsigned char LeftForward = 1;unsigned char LeftReverse = 2;unsigned char RightForward = 4;unsigned char RightReverse = 8;unsigned char PORTB_val;unsigned char PORTD_val;unsigned char in_char = 0;void setup() {//PORTD = digital IO 0-7//FireWeapon, horn, redLED, BlueLED pinMode(4, OUTPUT); // sets the digital pin as output pinMode(5, OUTPUT); // sets the digital pin as output pinMode(6, OUTPUT); // sets the digital pin as output pinMode(7, OUTPUT); // sets the digital pin as output//PORTB = digital IO 8 - 13 //LeftForward, LeftReverse, RightForward, RightReverse pinMode(8, OUTPUT); // sets the digital pin as output pinMode(9, OUTPUT); // sets the digital pin as output pinMode(10, OUTPUT); // sets the digital pin as output pinMode(11, OUTPUT); // sets the digital pin as output Serial.begin(9600); // set up Serial library at 9600 bps PORTD = redLED; // turn on the red LED #if DEBUG flash_led(3,500); #endif wait_for_start(); //Waits for startup message from router serial port //continues after receiving it.}void flash_led(unsigned int count, unsigned int rate){// debug routine that flashes an LED int n_count = 0; while (n_count < count) { n_count++; digitalWrite(13, HIGH); // sets the LED on delay(rate); // waits for a bit digitalWrite(13, LOW); // sets the LED off delay(rate); // waits for a bit }}char get_char(){//Function that waits for a character from the serial port//If none are received, it returns 0.//The timeout is so that if the router stops sending data to the microcontroller,//the micrcontroller will stop driving the car, rather than just going forever with//the last command. Timeout is around 250mS. while (loop_count < 30000) { loop_count++; if (Serial.available() > 0) { incomingByte = Serial.read(); loop_count = 0; return incomingByte; } } loop_count = 0; #if DEBUG Serial.print('X', BYTE); #endif return 0; }unsigned char wait_for_start(){//Waits for startup message from router serial port#if WAIT_FOR_START #if DEBUG Serial.println("Waiting..."); #endif while(1) { if (get_char() == 'j' && get_char() == 'b' && get_char() == 'p' && get_char() == 'r' && get_char() == 'o') { #if DEBUG Serial.print("Start Code Recieved"); #endif return 0; } }#endif}void loop() { //Function that processes input from serial port and drives the Robot based//on that input. in_char = get_char(); //Split byte received in to upper and lower halves. PORTB_val = in_char & 0x0F; PORTD_val = in_char & 0xF0; //Make sure the BlueLED is turned on now. if ((PORTD_val & BlueLED) == 0) { PORTD_val = PORTD_val + BlueLED; } //The following IF statements are sanity checks to make sure that LeftForward and LeftReverse cannot be on at the same time //and that RightForward and RightReverse can't be on at the same time. if ((PORTB_val & (RightForward + RightReverse)) == (RightForward + RightReverse)) { PORTB_val = PORTB_val - RightReverse; } if ((PORTB_val & (LeftForward + LeftReverse)) == (LeftForward + LeftReverse)) { PORTB_val = PORTB_val - LeftForward; } //Write the processed values to the ports. PORTD = PORTD_val; PORTB = PORTB_val; #if DEBUG Serial.print(PORTD, HEX); Serial.print(PORTB, HEX); #endif}
What about using car window regulator motors, because i believe they have internal gearing that would allow me to directly connect them to the wheels. Probably harder to get car window regulator motors, but I'm curious as to if they suck less power then a drill motor, Because i need this to have some force behind it.
Although i could go up to Sparky's Electronics, but they are miles away, And since i don't have a license, and my mom refuses to drive me there, I'm out of luck once again.
Here is my code [Snip]
and to answer the question as to why I'm using relays to switch relays is because if i have two relays wired in parallel and connected to a transistor (of course, i am using a diode across the relays coil leads) the relays will not actuate, the hum, and studder a little, but wont activate,
i was originally going to use the usual components to make the H-Bridge, but i soon realised i couldn't afford it. For crying out loud I'm using a old modified computer chassis as the chassis for this (maybe only temporarily, depends on how it works out )
the main concern i have is the amp draw from the motors, i would love to have some motors (with gearbox) that didnt suck too much amperage on startup, and under load, but still has the power a drill motor (with gearbox) has.
the main thing im worrying about, is powering the motors, while keeping a clean, 12 volt, noise free (as much as possible) power source to run the rest of the equipment off of.
yes i do have a bicycle, but Sparky's is about 15 miles away, in a bad part of town, a part of town i rather not be in.
Yes i know relays are fine for a h-bridge, but there are ways of making the h-bridge so much more compact, as in, not using relays that take up so much board space. and i knew going full speed all the time isnt the best, But i didnt know it would be so easy to make the H-Bridge speed variable, And now i must figure out how to implement that, and redo my controls setup to allow for it
after some quick googleing, i ran accross thishttp://www.blog.oreind.com/wp-content/uploads/2010/03/pwm-speed-rotation-forard-reverse-and-regenerative-braking.jpgi was wondering if this would work, based on the above link
Hi,Quote from: aouate3 on July 31, 2011, 02:40:55 PMyes i do have a bicycle, but Sparky's is about 15 miles away, in a bad part of town, a part of town i rather not be in.Just bring brass knuckles - the exercise will do you good
So something like this? i added the transistor for
Brass knuckles, yea that will work well, right up untill someone pulls a gun and blows me into the afterlife... I live in Fresno,Ca the gangs here wouldnt think twice about shooting me, hince why i stay away.
I will definitely contact sparkys and ask them about that, Also do you know any alternatives to the buzz11 ? Because it seems pretty hard to find. and out of curiosity i searched it on ebay, and there was only one listing, and it was like $6 per fet...
Also, is the mps2222A transistor a good alternativeto the 2n2222a ? i know i should just pull up the datasheets for them, but i was wondering if you had any personal experince using the mps2222a transistor instead of the 2n2222a
found someone that can order stuff from ebay for me, going to order some bc337 transisitors, found this [Snip link)tell me what you think, i know there are 100 of them, but hey, i could use them over time
Also will the IRF510 mosfet work for the speed controller?
also, do you think i might be able to get a mosfet from a old sharper image ionic breeze fan? i have one that is dead, and im sure that it has digital controls, so it might have a mosfet that may work, ill open it up and take a look. its cheaper gutting things for parts then it is to buy parts, so if you know of anything that has useable mosfets, please tell meno mosfets in the fan, only transistors, ir reciever, leds, a "superchip" capicitors and resistors, a button board, a speaker, and a few diodes...
check these out, tell ,me if any of these will work, i checked the datasheets and they look like they will work, but i want to get a professional oppion[Snip links]and yes, bulk is better, that way if i mess up, i can redo it, also to build more in the future
also if you have time, and if its not a hassle, search on ebay for a bulk sale for a compatible mosfet, at a low-ish price (as low as you can find preferablly) if you can only find one of like 10 pieces or so, thats fine
i found some power mosfets on a tv power supply board, they are IRF1644G, i have been unable to find a datasheet for them, it seems like they dont exist!... but i built a circuit with on, and its not working... so yea... if you can find the datasheet for this fet, i would be happy, because i have a feeling that this fet isnt compatible...
there is always a output.... of 12 volts... and i dont know why.. im pretty sure its wired right... it must just be a non-compatible mosfet...
so far i have dissassembled 2 desktop power supplies, a vcr, tv powersupply board, all of the transistors and fets have given me false hope... after looking up there datasheet.. most of the parts are npn switching, pnp swithing, diode bridges, shunt regulators, and some other ones... kind of dissapointing.. but i now have a bunch of heatsinks for the mosfets i guess thats a plus
also, in the vcr.. which was sitting in my living room for years, there was a spider, so now i have a spider roaming around my room... oh fun.... it was on my arm earlier, tried to slap it off, it fell off, havent seen it since... little buggers....
[...] If the current handling is large enough, a single of them can be used to protect the MOSFETs in both sides.
i was going by the schematic you posted, maybe i am doing something wrong,
i also found a k3067 mosfet, wired it up, to the exact same circuit, and on this one im not getting any output... very confusing... ill try putting a resistor on it, but if that doesnt work, then im either reading the schematic wrong, or something is wrong with the schematic...
iAlso i have been wondering what i should do with the 2 capicitors i have sitting on my desk, they are 250 volt 1000 microfarad capicitors, also i have about 12 200 volt 470 microfarad capicitors... if only i could find my capicitor chargeing circuit...
Most MOSFETs, when looking at the lettering, pins pointing down, has the pinout left to right: Source, Drain, Gate.
ok, ill get 2 of the TIP120 transistors for switching relays for reverse, and 2 of the TIP42G transistors for pwm.Do you think these are good choices? possibly for final boardor should i get 4 TIP120 transistors?