What is the best way to learn 8 bit Assembly?
I have "16 BIT LANGUAGE TOOLS GETTING STARTED" DS70094E. My 16F887 is an 8 bit machine. What is the best way for me to learn ASM for my PIC? I have not been able to get MPLAB IDE v8.33 to work. Is that because I am dealing with an 8 bit PIC?
Ken
It did not like the ASM code
I gave MPLAB IDE some .asm code created by MicroCode Studio. It claimed too many errors. That was many months ago. I'll try again.
Ken
PICKIT 2 Programmer Application??
I've built my first solderless proto using a 40 pin 16F887.
As far as I can tell I have duplicated the actions that up until now have worked. The PICKIT 2 Programmer "Check communication" says "PICKIT 2 found and connected" "PIC device found"
However when I click the Write button using the 40 pin PIC, the PICKIT 2 Programmer application says "Programming failed at program memory address LOCATION 0x000002"
Any ideas?
Ken
Cool chip for R/C PWM: 18F2431 series
After reading about some of Bruce's cool projects with the 18F2431 series chips, I have been playing around with them for a little while. One thing that caught my eye is that they can do Power Control PWM as low as 19 hertz (while running at 40 mhz). Something you have to bring other chips OSC down to 0.5 mhz to do. This, and a few more of it's features, make it pretty nifty for creating PWM servo output. I mocked up a quick test, and have been able to do about 10bit PWM 1 to 2ms pulses at the proper 50 hertz spacing on 3 pins with the 18F2431. The larger chips of this series can do 4 pin PCPWM. I will post a little code once I get it cleaned up a bit.
The new Electronic Speed Control is messing with my head
I received a brand new HPI Racing Sprint car. This is the same model which I have been using. It is just the most recent version.
I am having a problem with the new Electronic Speed Control a SC-15. It has some kind of mind of its own. My old code which told my old car where to go is not working with this new ESC.
Do any of you have the contacts to get me the specs on this "SC-15 ESC WITH REVERSE SPORT CONTROL".
Does is have a PIC? Is it programmable? What are its design algorithms?
Ken
Servo pwm passthrough using PCPWM
The 18F2431 makes it slightly easier to perform servo PWM because it's PCPWM module can go down to 19 htz while maintaining fast OSC rates, unlike other PIC chips HPWM. Here is an example of using the PCPWM to output 3 servo signals. This specific example senses the pulses (up to 5 channels) by using the CCP1 capture pin. To get 5 channels into one pin for PW capture, channels 1, 3 and 5 are input using small signal diodes. Then, since this drops the signal down to under 3 volts, I used two 2n3904 transistors. One to boost up the voltage, and the other one to invert the signal back to normal. (It was all I had lying around). Somehow, you will need to boost your signal after the diodes for the CCP1 capture to sense the incoming pulses.
Note: Because the PCPWM was used, this will not work on any chip outside of the 18F2431 family.
Code:
;This only works on a 18F2431 family device with Power Control PWM (PCPWM)
;By Scale Robotics Inc.
; The input signal should look something like this:-
;
; |<------------------ 1 frame (~20mS) -------------->|
; |<1~2mS>
; ______ ______ ______ ______
; _______| |______| |______| |________________| |____
; gap ch1 ch2 ch3 ch4 ch5 sync gap ch1 etc
define OSC 40
asm
__CONFIG _CONFIG1H, _OSC_HSPLL_1H
__CONFIG _CONFIG2H, _WDTEN_OFF_2H & _WDPS_512_2H
__CONFIG _CONFIG4L, _LVP_OFF_4L
endasm
clear
ADCON0 = %00000000
ADCON1 = %00000000
portb=0
trisb = %11000000
trisc = %00000110
trisa = %00000000
DTCON = %00000101 'dead time for complimentary ouputs
PTCON0 = %00001101 '1:1 postscale, Fosc/4 1:64 prescale, Sincle Shot mode
PTPERL = 255 '
PTPERH = 251
PWMCON0 =%01010000 'PWM[5:0] ouputs enabled
PWMCON1 = 1 'updates enabled, overrides sync w/timebase
PTCON1 = %10000000 'PWM timebase is on, counts up
FLTCONFIG = %00000010 'disable fault A, cycle by cycle mode
CCP1CON = %00000101 'Capture mode; every rising edge
duty1 var word 'width of outgoing pulse1
duty2 var word 'duty values 625 to 1250 = 1 to 2 ms pulse (Center at 625)
duty3 var word
risetime1 var word 'Rise Time for incoming pulse1
risetime2 var word
risetime3 var word
falltime1 var word 'falltime for incoming pulse1
falltime2 var word
falltime3 var word
pulsewidth1 var word 'pulse width for incoming pulse1
pulsewidth2 var word
pulsewidth3 var word
pulsewidth4 var word
pulsewidth5 var word
pulseNumber var byte
pulseNumber = 1 'tells which pulse we are reading
CCP1CON.0 = 1
timerone var word
timerone = 60315 ;
INCLUDE "DT_INTS-18.bas" ; Base Interrupt System
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler TMR5_INT, _PulseOut, ASM, yes
INT_Handler CCP1_INT, _PulseMeasure, ASM, yes
INT_Handler TMR0_INT, _TimeOut, ASM, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
T1CON = %00110001 ;Timer1 used by CCP1 capture
T5CON = $01 ;used as pulseout timer
T0CON = %11000111 ; Prescaler = 8, TMR1ON
@ INT_ENABLE TMR5_INT ; Enable Timer 1 Interrupts
@ INT_ENABLE CCP1_INT ; Enable Capture Compare for pulse width measurement
@ INT_ENABLE TMR0_INT ; deadtime (sync gap) indicator for lull between pulses
Main:
pause 10
'do something to these values if you want to filter, center, etc
'Below we are just passing values through
duty1 = pulsewidth1 >>1 'send channel 1 out PCPWM on PortB.1
duty2 = pulsewidth3 >>1 'send channel 3 out PCPWM on PortB.3
duty3 = pulsewidth5 >>1 'send channel 5 out PCPWM on PortB.4
GOTO Main
'---[TMR5_INT - interrupt handler]------------------------------------------
PulseOut: 'set up pulse width values for pulseout and reset single shot bit
TMR5L = timerone.byte0
TMR5H = timerone.byte1
PDC0L = duty1.lowbyte
PDC0H = duty1.highbyte
PDC1L = duty2.lowbyte
PDC1H = duty2.highbyte
PDC2L = duty3.lowbyte
PDC2H = duty3.highbyte
PTCON1.7=1 'resets single shot PTEN bit
@ INT_RETURN
'---[CCP1_INT - interrupt handler]------------------------------------------
PulseMeasure:
if CCP1CON.0 = 1 then ; Check CCP1M0 for rising edge watch
select case pulseNumber
case 1
TMR0L = 0 'reset timeout timer0
TMR0H = 0
risetime1.lowbyte = CCPR1L
risetime1.highbyte = CCPR1H
case 2
TMR0L = 0 'reset timeout timer0
TMR0H = 0
risetime2.lowbyte = CCPR1L
risetime2.highbyte = CCPR1H
case 3
TMR0L = 0 'reset timeout timer0
TMR0H = 0
risetime3.lowbyte = CCPR1L
risetime3.highbyte = CCPR1H
End select
@ BCF CCP1CON, CCP1M0 ; Now capture the trailing edge
Else 'check for falling edge time
@ BSF CCP1CON, CCP1M0 ; Re-set for trailing edge capture
select case pulsenumber
case 1
falltime1.lowbyte = CCPR1L
falltime1.highbyte = CCPR1H
pulsewidth1 = falltime1 - risetime1
case 2
falltime2.lowbyte = CCPR1L
falltime2.highbyte = CCPR1H
pulsewidth2 = risetime2 - falltime1
pulsewidth3 = falltime2 - risetime2
case 3
falltime3.lowbyte = CCPR1L
falltime3.highbyte = CCPR1H
pulsewidth4 = risetime3 - falltime2
pulsewidth5 = falltime3 - risetime3
end select
pulsenumber = pulsenumber + 1 'get ready for next channel
endif
@ INT_RETURN
'---[TMR0_INT - interrupt handler]------------------------------------------
TimeOut:
pulsenumber = 1 'if pause between pulse in exceeds about 7 ms, get ready
'to receive pulse 1 (senses dead time between pulse bursts)
@ INT_RETURN
To see a similar project, but using SPWM, look here: http://www.picbasic.co.uk/forum/showthread.php?t=12657
I think this ESC is different
I agree with both of you on the size, shape and frequency of standard PWM signals. I have been running my car (an older version of this same HPI Sprint) successfully for the last couple of months. With the exception of frequency my HPWM pulses agree with your specs. I found the correct HPWM commands by trial and error.
This new Transmitter, Receiver, ESC combo is different. Leaving out my PIC for the moment if I on the radio transmitter I give full forward (trigger full back) and suddenly go to full reverse (trigger full forward) the car goes from full forward to stop (neutral in the PWM sense) and stays there until I bring the trigger to neutral for at least two seconds. Then giving it full back will work fine.
Somewhere in the system is protection against slamming the DC motor with reversed polarities. That is good, but when I tried to emulate that system in my code it did not work.
Thank you sooo much for your support and interest. Oh, yes, the electronic speed control wheel driving system is not a classic servo. Steering is. Wheels used to be - in the day - but no longer.
Ken
Just got back into town...
OKAY,
I have discovered through the use of my oscilloscope that PAUSE stops the HPWM output pulses. In order to emulate the radio system I want to try giving the ESC two seconds worth of neutral PWM between switches back and forth between forward and reverse. This is a race car. It will not be going backwards very often, but it is necessary sometimes. Looks like I need to figure out how to set a two second interrupt. Hmmmm. NUTS!
Ken
wiring correctly eases understanding BASIC
Yup,
Now when it sees something in front it stops then goes backwards. :) And when nothing is in front it goes forward for all its worth. Such a difference getting the steering servo and the wheel electronic speed control signals actually going to the servo and the ESC.:o
Now to calibrate HPWM for this fancy ESC. It seems very similar, but not exactly like the old not-so-fancy ESC. There are still funny rules around switching from forward to reverse and visa verso.:)
Ken
New car - its first outing
It worked better before I went in and to get my video camera. However, you can get the idea from this clip. There are still some mysteries :confused: with the HPI's new Electronic Speed Control SC-15.
http://www.youtube.com/watch?v=4oFTzyMuSjA
Little by little....
Ken
I ran for two minutes autonomously
This afternoon I taped a two minute video in which my new HPI Sprint car ran autonomously around and around the inside of our garage. The radio transmitter was turned OFF during the whole episode. At no time in this piece did I interrupt the PIC control with the radio control. I was operating the video camera.
Go to:
http://www.youtube.com/watch?v=jI5JEeT_FDE
What do you think?
Ken:):)
What version of code is in my PIC
If I have recorded the checksums how can I know which version of code is on my PIC?
The PIC KIT 2 programmer has a READ button. Does that read the contents of my program memory and display for me to see its checksum?
I have not figured out on-line debugging. Actually I have not figured out a great deal of stuff in this system.
Ken