Hi. I'm a bginner in robotics and been working on my first bot for a week now. I have it "up and running" with basic (bump switch based) navigation. Now I'm implementing IR object detection and I've run into a problem I can't seem to overcome...
I'm using mostly recycled parts for the bot, except for the PIC16F876A microcontroller. So my IR system consists of one TSOP1738 IR reciever and two IR leds from old TV remotes. I have everything wired to the PIC and the receiver works...somewhat when I point a remote at it and press buttons. Sometimes it gets a reading and sometimes not. It might be that the remotes aren't exactky 38kHz so that's not a big problem. The big problem is, that my IR leds don't want to communicate with the reciever. I'm using PWM to modulate the IR light at exactly 38kHz, but I suspect I have not set up the hardware PWM correctly.
Code:
BANK1
movlw 0x34 ;PWM period
movwf PR2
BANK0 ; register bank 0
bsf CCP1CON, 4 ; Determine
bcf CCP1CON, 5 ; PWM duty cycle
movlw b'01000000' ; initial duty cycle
movwf CCPR1L
BANK1 ; register bank 1
bcf TRISC, 2 ; port c is an output
BANK0 ; register bank 0
movlw b'00000100' ;
movwf T2CON ; PWM on TIMER2
could someone help me calculate the appropriate values to get the led blink at exactly 38kHz? And explain the values aswell.
It's easier to get an accurate frequency if you use a simple software loop to generate the 38KHz, as you also only need to generate a few cycles (and on different pins), it's probably the best way.
DUH! Hehe, I forgot to add the clock frequency indeed...
I'm using an 8MHz resonator.
And, well...if someone could tell me how many ms is one Hz, I could use the software loop using the basic WAIT/WAITX macro, right?
P.S.
Excuse me if I ask stupid or simple questions at times. The whole assembler language and coding is new to me aswell and I think I have an information overdose by now from all those tutorials and howto's.
Ok, I set aside the IR object detection project for a bit and concentrate on the carriage of the bot. I'm using a pair of stepper motors from a 'Brother' electrical typewriter, but they don't do the job too well... They are a version of PM25L-s from Mineba Electronics. And I can't get the torque I need from them. My bot is 10x10cm and has two 5cm dia wheels which I got from breaking apart a set of office chair wheels.
I'm using four 1.2V AAA rechargeable batteries to power the two motors. Is there any way to increase the torque? The typewriter was feeding the motors 5V so I guess that's their working voltage. Would increasing voltage/current help?
So I guess there's no way to increase the torque other than getting new steppers... Ok, I'll settle with what I have for now and continue to work with the IR obstacle detection. The bot is a test platform for learning how things work anyways. So I'll just keep in mind to get decent motors for my 'real' bot
So I guess there's no way to increase the torque other than getting new steppers... Ok, I'll settle with what I have for now and continue to work with the IR obstacle detection. The bot is a test platform for learning how things work anyways. So I'll just keep in mind to get decent motors for my 'real' bot
Stepper aren't a good choice for a simple robot, you can increase torque by feeding them from a far higher voltage through a high wattage series resistor - but this is obviously inconvenient on a robot.