+ Reply to Thread
Page 3 of 20 FirstFirst 123456713 ... LastLast
Results 81 to 120 of 772
  1. #81
    Join Date
    Nov 2009
    Location
    Fitchburg, Mass
    Posts
    483

    Default Up to page 19 in DS33014K

    At last I am getting the correct reference materials.

    DS33014K is telling me about MPASM Assembler, Library and Linker.

    I have ordered from Belgrade "PIC Microcontrollers". It is being shipped by air. That alone is pretty amazing. Just a little paperback book.

    I have also found an online book at:

    http://www.mikroe.com/en/books/picmcubook/ch0/

    It may be the same book only on line. I am old fashioned. I like to read from paper.

    I have plenty of studying to do. Thank you again and again.

    Ken

  2. #82
    Join Date
    Nov 2009
    Location
    Fitchburg, Mass
    Posts
    483

    Default mackrackit: where do I get your .INC

    I copied your code snip from POST #73 at 3:02 on the 28th of January.

    I noticed in the .asm code that it wanted to:

    INCLUDE "MACKRA~1.MAC"

    There is no such file in my computer. Do I need a copy? May I have one?

    Also the compiler complained that:

    Error 118: "Overwriting previous address contents (2007)

    Page 157 of DS33014K says that Error 118 occurred because "Code was previously generated for this address" I assume it is talking about address (2007). I do not see where in the .asm code this is happening. I do not even know what to look for.

    Ken

  3. #83
    Join Date
    Nov 2009
    Location
    Fitchburg, Mass
    Posts
    483

    Default I need to send one pulse every 20ms

    Mackrackit,

    From what I understand your code will do a PWM every time TMR0 overflows.

    What I need to do is make this overflow happen every 20ms. That is 50 pulses per second. We have a 4 meg oscillator. If I were designing this counter I think I would have it set to 20,000 each time it overflows. I gather from page 74 of the Data Sheet that this is not possible. The biggest prescaler is 256.

    How about a routine that counts these interrupts until 1/50 of a second has elapsed then calls PWM? I would have it send one pulse out pin 1 with the duty as defined by "duty". It would look like

    PWM 1,duty,1

    I have found a section on Timers in a book called Running Small Motors with PIC Microcontrollers that has an example of MicroEngineering Labs code that makes an eight digit LCD display the time in hours, minutes and seconds. I think this code must do something like I need.

    Ken

  4. #84
    Join Date
    May 2007
    Posts
    604

    Default

    You want 20,000 counts before it overflows. Setting the prescaler to 1:256, you will need 20,000/256 counts = 78. The counter rolls over (overflows and sets T0IF) when it reaches 255, so if you pre-load it with 255-78 = 177, then it will overflow approximately every 20mS.

  5. #85
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,926

    Default

    Quote Originally Posted by Kenjones1935 View Post
    I copied your code snip from POST #73 at 3:02 on the 28th of January.
    I noticed in the .asm code that it wanted to:
    INCLUDE "MACKRA~1.MAC"
    There is no such file in my computer. Do I need a copy? May I have one?
    Looks like you have the code named MACKRACKIT?
    The *.MAC file is the macro file generated by PBP. It will be in your project directory. The name is chopped to the 8.1? standards.
    Also the compiler complained that:
    Error 118: "Overwriting previous address contents (2007)
    Page 157 of DS33014K says that Error 118 occurred because "Code was previously generated for this address" I assume it is talking about address (2007). I do not see where in the .asm code this is happening. I do not even know what to look for.

    Ken
    Looks like you are setting the configs in the *.inc file. I have them in the code. Just comment that line out and it should be OK.
    Dave
    Always wear safety glasses while programming.

  6. #86
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,926

    Default

    Quote Originally Posted by Kenjones1935 View Post
    Mackrackit,
    From what I understand your code will do a PWM every time TMR0 overflows.
    The code in post #73 will toggle a LED when TMRO overflows. The LED on PORTD.7 will gradually become brighter then turn off and start over again.

    This was just an example of an interrupt working with something else going on.

    You do have to be careful with this as things will sometimes not work as expected. Like they say, the machine will do what it is told, not what you want

    This is the same code as in post #73 with some modifications to demonstrate a "pitfall".
    The START loop still has PORTD.7 PWMing the LED with PORTD.0 added to be toggled.
    Inside of the interrupt loop the same PWM that is on PORTD.7 is now on PORTD.6.

    What do you think will happen?
    What does happen?
    Code:
    '16F887 INT RUPT
    '44 PIN DEMO BOARD
    
     @ __config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _LVP_OFF & _CP_OFF
    
     INTCON.5 = 1    'ENABLE TMR0  DATA SHEET SECTION 14.3.2
     OSCCON = %01110000 '8 Mhz
     OPTION_REG = %10000111  ' 1:256 PRESCALE
     ON INTERRUPT GOTO TLOOP
     CNT  VAR BYTE
     D    VAR BYTE
     D = 0
     HIGH PORTD.0
     PAUSE 500
    
     START:
     FOR CNT = 0 TO 150
     PWM PORTD.7,D,100
     D = D + 2
     NEXT CNT
     TOGGLE PORTD.0
     PAUSE 100
     GOTO START
    
     DISABLE
     TLOOP:
     INTCON.2=0 ' DATA SHEET SECTION 14.3.2
     TOGGLE PORTD.4
     FOR CNT = 0 TO 150
     PWM PORTD.6,D,100
     D = D + 2
     NEXT CNT
     RESUME
     ENABLE
    Dave
    Always wear safety glasses while programming.

  7. #87
    Join Date
    Nov 2009
    Location
    Fitchburg, Mass
    Posts
    483

    Default Code in #73 WORKS!!

    Just like you said it would.

    Now on to your next one. It compiles and works also. I see what it does. I need to figure out how.

    Thank you!!

  8. #88
    Join Date
    Nov 2009
    Location
    Fitchburg, Mass
    Posts
    483

    Default A definition pleas...

    Can anyone point me to a definition of "prescaler".
    What I thought it meant does not seem to jive with what I am seeing.

    Ken

  9. #89
    Join Date
    Nov 2009
    Location
    Fitchburg, Mass
    Posts
    483

    Default My book fell open to the correct page.

    "Running Small Motors with PIC Microcontrollers" says, on page108

    "A pre-scaler is applied to the system clock and affects the timer by slowing down the system clock as it applies to the timer. Normally the timer is fed by a fourth of the basic clock frequency, which is called Fosc/4. In a system running a 4 MHz the timer sees a clock running at 1 MHz. If the pre-scaler is set for 1:8, the clock will be slowed down by another eight times, and the timer will see a clock at 125kHz."

    "The post-scaler setting determines how may overflows will go by before an interrupt is triggered."

    If I pre-scale TMRO 1:256 I will get overflows at about 4K per second. If I add a post-scaler of 1:64 I will end up with about 62 interrupts per second.

    Close enough for government work?

    Ken

  10. #90
    Join Date
    Nov 2009
    Location
    Fitchburg, Mass
    Posts
    483

    Default OOPs. There is only one scaler.

    I just found in DS33023 section 11.6.

    "There is only one pre-scaler available which is mutually exclusively shared between Timer 0 and Watchdog Timer."

    So I have to count the 4000 Interrupts per second using a

    FOR CNT To 80
    NEXT

    loop. That will give me much closer to 50 pulses per second.

    Correct?

  11. #91
    Join Date
    May 2007
    Posts
    604

    Default

    See my post #84 above. Which part is unclear to you?

  12. #92
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,926

    Default

    Hi Ken,

    I always get confused with this part of things too, so I will just point you to a couple of threads that I refer to when the need arises.

    I think maybe the parts about
    TMR1L
    TMR1H
    are the things you need to look at???

    http://www.picbasic.co.uk/forum/showthread.php?t=961
    http://list.picbasic.com/forum/messa...tml?1049090059
    Dave
    Always wear safety glasses while programming.

  13. #93
    Join Date
    Jul 2003
    Posts
    2,405

    Default

    You could simplify this a great deal if your PIC has Timer1 available, and Compare,
    Capture, PWM .. by just using the Compare peripheral.

    Here's an example:
    Code:
        DEFINE OSC 4
    
        Match VAR WORD
        
        Match   = 20000         ' 20,000 * 1uS = 20mS until compare match
        CCPR1H  = Match.HighByte' Load compare register high
        CCPR1L  = Match.LowByte ' Load compare register low
        CCP1CON = %00001011     ' Compare mode, auto reset Timer1
        
        '/ TRIS & Port Setup
        PORTB.0=1
        TRISB = $FE  ' PORTB.0 output, rest inputs
        
        '/ disable interrupts
        INTCON.7 = 0 ' Disable global ints
        INTCON.6 = 0 ' Disable peripheral ints
        PIE1.0   = 0 ' Disable Timer1 int
        PIE1.2   = 0 ' Disable CCP1 int
    
        T1CON = %00000000 ' Timer1 off, internal clock, 1:1 prescale
        TMR1H = 0         ' Clear Timer1 high
        TMR1L = 0         ' Clear Timer1 low
        
        T1CON.0 = 1  ' Turn on Timer1
    
    LOOPS: ' NOTE: PIR1.2 is the CCP1IF compare interrupt flag bit.
           ' this bit is set when Timer1 reaches the value in
           ' CCPR1L & CCPR1H
        IF PIR1.2 = 1 THEN   ' If CCP1 to TMR1 compare match occured
           PORTB = PORTB ^ 1 ' Toggle PORTB.0
           PIR1.2 = 0        ' Clear compare interrupt flag bit
        ENDIF
        GOTO LOOPS
    
        END
    Just 1 single interrupt could take care of your 20mS timing VS a bunch to accumulate the
    total 20mS time period.

    A single interrupt every 20mS & no reloading anything. Timer1 is automatically cleared on
    match, and the CCPR1L/CCPR1H registers contain the value loaded into them until you
    change it.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  14. #94
    Join Date
    May 2007
    Posts
    604

    Default

    For 20mS timing, you can do it with a single interrupt with any of the 3 timers on the PIC16F887.

    Timer0 - Set prescaler to 1:256
    Timer1 - As shown above by Bruce
    Timer2 - Set prescaler to 1:16, set postscaler to 1:16

  15. #95
    Join Date
    Nov 2009
    Location
    Fitchburg, Mass
    Posts
    483

    Default I think I am beginning to understand.

    It seems to me that the most important feature that must be continuously timed in my RC car in autonomous control is the 50 pulses per second Pulse Width Modulated simulation of the RC Receiver to Electronic Speed Control signal. Doing this job in background with one Interrupt sounds correct.

    The oscillator seen by TMR0 with pre-scaler runs at 1000000Hz

    The pre-scaler 1:256 cuts that down to 3906.25. ie 4kHz.

    A post-scaler of 1:64 cuts this down to 61.035Hz. Close enough is my guess. I don't have a grip on how to code this yet. Do I at least understand the concept?

    -----------------------another way---------------

    Bruce suggests counting up to 20,000 in bits of 1 microsecond. That should be easy enough with a 16 bit register built from TMR1H and TMR1L.

    ------------now how do I get only one PWM pulse?----------------

    Page 135 of the PBP manual seems to indicate that the command:

    PWM Pin,Duty,Cycle

    will produce "Cycle" number of pulses. It says, "This PWM cycle is repeated "Cycle" times." It also says that, "If a 4mHz oscillator is used, each "Cycle" is about 5ms long."

    This seems to mean that the following command:

    PWM 1, 75, 1

    would produce one pulse about 1.5msec long. This is the neutral pulse for a ESC.

    If this is true then writing a routines to control the drive wheels and the steering servo will not be difficult at all.

    What do you think?

    Ken

  16. #96
    Join Date
    Nov 2009
    Location
    Fitchburg, Mass
    Posts
    483

    Default Bruce's counter works

    I can count up to 60,000 micro seconds using Bruce's mechanism. This is long enough to make the LED on PORTD.0 blink visibly!

    Next step is to add the PWM command and connect the output to my RC car's ESC box.

    Thanks again, All

    Ken

  17. #97
    Join Date
    Jul 2003
    Posts
    2,405

    Default

    This is pretty crude, but see if it does what it should when changing to Forward, Back, etc
    with your ESC.
    Code:
        DEFINE OSC 4
    
        Match VAR WORD
        
        Forward CON 1000     ' ~1mS pulse
        Neutral CON 1500     ' ~1.5mS pulse
        Back    CON 2000     ' ~2mS pulse
        
        Match   = 20000         ' 20,000 * 1uS = 20mS until compare match
        CCPR1H  = Match.HighByte' Load compare register high
        CCPR1L  = Match.LowByte ' Load compare register low
        CCP1CON = %00001011     ' Compare mode, auto reset Timer1
        
        '/ TRIS & Port Setup
        PORTB.0=1
        TRISB = $FE  ' PORTB.0 output, rest inputs
        
        '/ disable interrupts
        INTCON.7 = 0 ' Disable global ints
        INTCON.6 = 0 ' Disable peripheral ints
        PIE1.0   = 0 ' Disable Timer1 int
        PIE1.2   = 0 ' Disable CCP1 int
    
        T1CON = %00000000 ' Timer1 off, internal clock, 1:1 prescale
        TMR1H = 0         ' Clear Timer1 high
        TMR1L = 0         ' Clear Timer1 low
        
        T1CON.0 = 1  ' Turn on Timer1
    
    LOOPS: ' NOTE: PIR1.2 is the CCP1IF compare interrupt flag bit.
           ' this bit is set when Timer1 reaches the value in
           ' CCPR1L & CCPR1H
        IF PIR1.2 = 1 THEN   ' If CCP1 to TMR1 compare match occured
           HIGH 0
           PAUSEUS Forward   ' change this to Neutral, Back, Forward to see effect
           LOW 0
           PIR1.2 = 0        ' Clear compare interrupt flag bit
        ENDIF
        GOTO LOOPS
    
        END
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  18. #98
    Join Date
    Nov 2009
    Location
    Fitchburg, Mass
    Posts
    483

    Smile Bruce, SUCCESS

    Not only does your code work (with a couple of adjustments specific to my PICkit 2 setup) but it also makes my car go not-so-fast, faster, and fastest.
    It also successfully drives the steering servo left, center and right. This validates the rumors that I was getting from the RC people about the shape and timing of their PWM signals.

    GREAT!! Now on to bigger and better stuff like light sensing and proximity sensing. First I need to write some car control routines

    FORWARD speed,duration
    BACKWARD speed, duration
    STEER_RIGHT ?
    STEER_LEFT ?



    Ken

  19. #99
    Join Date
    Nov 2009
    Location
    Fitchburg, Mass
    Posts
    483

    Question Maybe not so fast...

    Am I correct in thinking that PAUSEUS stops the PIC.

    To run my car the PIC must control steering and wheel rotating. It also monitors whether channel 3 from the RC receiver is calling for a return to RC control.

    Meanwhile the car must be able to sense and react to light, ultra sound proximity, and other timers. It has to find its way to a destination.

    The PWM pulses are generated at 50 per second. That is 20ms between clock matching interrupts. The longest PAUSEUS is 1.75ms which is 8.75% of total time. Steering concurrent with wheel rotation could consume 17.5% of compute time.

    Is this a problem? I just don't know enough about real time PIC coding to know the answer. What do you all think?

    Ken

  20. #100
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,926

    Default

    PAUSE puts the code into a loop for a certain amount of instructions. It does not stop the hardware interrupts.

    This is what a PAUSE in ASM looks like. Just a routine to eat some time.
    Code:
    ; Delay = 0.1 seconds
    ; Clock frequency = 4 MHz
    ; Actual delay = 0.1 seconds = 100000 cycles
    ; Error = 0 %
    Delay	;99993 cycles
    	movlw	0x1E
    	movwf	d1
    	movlw	0x4F
    	movwf	d2
    Delay_0
    	decfsz	d1, f
    	goto	$+2
    	decfsz	d2, f
    	goto	Delay_0	;3 cycles
    	goto	$+1
    	nop		;4 cycles (including call)
    	return
    Dave
    Always wear safety glasses while programming.

  21. #101
    Join Date
    Jul 2003
    Posts
    2,405

    Default

    If you have hardware interrupts enabled, it will jump out of any code routine, execute whatever code you have in your interrupt handler, then return to where it was prior to the interrupt.

    Note I wasn't recommending you use this routine to control your motors, I was just curious if it worked. Once you know what you'll need to do to handle all the other things you need to like light sensing, ultrasonic, etc, then you'll have some idea of how to incorporate all your routines (or most) into a single interrupt handler.

    Your particular type of application could also benefit from a few dedicated application specific ICs like maybe some 8-pin PICs programmed to do nothing but generate your motor control signals by just monitoring a few inputs, and using these inputs to determine speed, direction, etc. Then you main controller could control motors by just taking a pin or 2 high or low.

    A lot of robotics applications use distributed processing like this to take some of the repetitive tasks off of the primary controller.

    Example: Instead of using a sonar sensor, you could build this into your main controller. But then your main controller wastes a ton of time doing what the external sonar sensor does.

    So - most people will just buy & use a sonar sensor rather than design it into the main circuit. Just take that a step further, and make your own 8-pin servo controllers.

    If you have a lot of things going on, motors, sensors, measurements, etc, etc, you can take a huge burden off the main controller by just creating a few of your own litle application specific PICs with a few I/O-pins on the primary controller telling them what to do.

    You could have a whole herd of little 8-pin PICs interfaced & controlled by the primary controller, and it only takes a few pins on the primary to control them, and just a few instruction cycles to make that happen.

    Or you could shove it all into just one with some crafty interrupt handler to sort it all out. Just an idea. Sounds like a fun project.

    Microchip has a new 8-pin PICs coming shortly with a hardware USART & other goodies that could make some really interesting little peripheral controllers.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  22. #102
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,541

    Wink

    Quote Originally Posted by Bruce View Post
    Microchip has a new 8-pin PICs coming shortly with a hardware USART & other goodies that could make some really interesting little peripheral controllers.
    Hi, Bruce ...

    Could you give some little details ... please ??? a number ???

    I have been DREAMING of it for so long !!!

    Alain

    PS: 1822 ???
    Last edited by Acetronics2; - 4th February 2010 at 10:45.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  23. #103
    Join Date
    Jul 2003
    Posts
    2,405

    Default

    Hi Alain,

    Yes. It's the 8-pin PIC12F1822.
    Code:
     Enhanced Mid-range Core with 49 Instruction, 16 Stack Levels
     Flash Program Memory with self read/write capability
     Internal 32MHz oscillator
     Integrated Capacitive mTouch Sensing Module
     Data Signal Modulator Module
     MI2C, SPI, EUSART w/auto baud
     ECCP (Enhanced/Capture Compare PWM) Module
     Comparator with selectable Voltage Reference
     4 Channel 10b ADC with Voltage Reference
     25mA Source/Sink current I/O
     Two 8-bit Timers (TMR0/TMR2)
     One 16-bit Timer (TMR1)
     Extended Watchdog Timer (EWDT)
     Enhanced Power-On/Off-Reset
     Brown-Out Reset (BOR)
     In Circuit Serial Programming (ICSP)
     On Board In-Circuit Debug
     Wide Operating Voltage (1.8V Ė 5.5V)
     Low Power PIC12LF182x variants (1.8V Ė 3.6V)
     Standby Current (PIC12LF182X):  30 nA @ 1.8V, typical
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  24. #104
    Join Date
    Nov 2009
    Location
    Fitchburg, Mass
    Posts
    483

    Red face Feeling a bit overwhelmed

    Guys and Gals,

    I might take a side trip to a scenic view along this road.

    Here is a pointer to a BASIC (which BASIC I do not know) program that controls a toy level RC car. Toy levels have no Electronic Speed Control. The DC motor and servo are driven by direct current controlled by four DPDT switches. (Bang-Bang: full speed forward, full stop, full speed back.) This project has only autonomous control. The radio receiver has been eliminated. These simplifications plus the fact that the details are on the WEB make this diversion very tempting.

    http://letsmakerobots.com/files/wall_racers.bas
    and
    http://letsmakerobots.com/node/928

    I have an appropriate RC car.
    I have a spare PICkit2.
    I need to translate wall_racers.bas into PBP.
    I need to adapt the resulting ASM to my 16F887.
    I think I have enough proto. parts for both projects.

    My ego needs a boost.

    Ken:

  25. #105
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,926

    Default

    Ken,

    You are kind, intelligent, and I hear good looking.

    There is your ego boost

    Your new approach does sound like a good way to start. Save the PWM for later and work on the other parts.

    You may want to think about what Bruce said and go "modular". Then when you do get back to the PWM part it could live on a separate chip.

    You said you have some solder-less breadboards, so you could get a few of the 8 or 14 pin chips with ADC to play with. Remember MicrChip has a samples program so you could get three from them to start.
    Dave
    Always wear safety glasses while programming.

  26. #106
    Join Date
    Nov 2009
    Location
    Fitchburg, Mass
    Posts
    483

    Talking Lookit this great picture

    On the other hand==>

    Look at this great oscilloscope-like picture of the PWM pulses (fifty per second) very close to 1.75ms long created by Bruce's PAUSEUS technique. I finally figured out the Analyzer part of the PICkit 2 Logic Tool.

    Ken
    Attached Images Attached Images  

  27. #107
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530

    Default

    Quote Originally Posted by Kenjones1935 View Post
    On the other hand==>

    Look at this great oscilloscope-like picture of the PWM pulses (fifty per second) very close to 1.75ms long created by Bruce's PAUSEUS technique. I finally figured out the Analyzer part of the PICkit 2 Logic Tool.

    Ken
    Now that's progress! Great job Ken. That a pretty nice looking scope, and the price makes it look even better!

    Now you can see what you are doing .... er (or not doing).

  28. #108
    Join Date
    Nov 2009
    Location
    Fitchburg, Mass
    Posts
    483

    Smile It compiles and measures!!

    Fritsl's code compiles and runs on my PICkit2.

    The proximity detector (Devantech SRF05) responds with different size pulses (depending on the distance from it to an echoing object) when queried by this code.

    Next to prove out control of the four DPDT switches which steer DC to the motor and to the servo, destroy the toy car by ripping out its radio receiver. and figure out how to mount the PICkit, the switches board and the two SRF05's.

    Question. Is there any way that I can read through the PICkit programmer what is happening in real time to some of the variables. How do I think about adding debugging code?

    Ken

  29. #109
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530

    Default

    In case someone wants to measure multiple RC channels with one CCP1 pin, I did a small expermiment. If you connect every other RC receiver channel to CCP pin using 1N914 diodes (or similar), you will be able to measure pulses from three (or four) RC channels using one pin. Without the diodes, the RC channels that are low, ground out the one that is trying to pulse.

    Here is a picture of RC channels 2,4, and 6. Without a channel space between them, they stay high. So, with a PIC that has two CCP pins, you should be able to read all 8 channels!

    This picture shows scope yellow probe (rc 2, 4, and 6) with their diodes attached to the scope probe. and scope red probe directly attached to RC channel 2.

    Attached Images Attached Images  
    Last edited by ScaleRobotics; - 7th February 2010 at 03:18.

  30. #110
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530

    Lightbulb

    Come to think of it, using one CCP pin, you can decode (however many channels your RC transmitter has - 1). So, using a 6 channel transmitter, you can decode 5 channels using a chip with a single CCP compare pin. To do this, connect RC1, RC3 and RC5 channels from your receiver to the CCP pin with some diodes, and a pulldown resistor. Then capture every transition with capture. The in between pulses are RC channels 2 and 4.

    Now to write some code...

    Attached Images Attached Images  

  31. #111
    Join Date
    Nov 2009
    Location
    Fitchburg, Mass
    Posts
    483

    Default I've got the proto car together.

    Individually the parts of the system seems to pass their tests.
    The DPDT switches worked according to their truth tables.
    The proximity switches echoed what looked like sensible responses.
    The wheels turned and the steering responded as the DPDT switches asked of them.

    However, the car does not work as a system. The PIC is running. The proximity sensors have LED's that blink when pulsed. These work. After a while the proximity detectors stop. All this is in the code, but the steering does not move at all. The wheels do not reverse when something is seen to be right in front of the car.

    Question is: What kinds of debugging power do I have once the code is in the PIC besides the Logic Tool Analyze mode?

    Ken

  32. #112
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,819

    Default

    Quote Originally Posted by Kenjones1935 View Post
    Question is: What kinds of debugging power do I have once the code is in the PIC besides the Logic Tool Analyze mode?

    Ken
    You can hook up a serial LCD to the system and use debug to send the value stored in your variables, you can store port status in a variable and debug too.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    Tyranny is defined when law enforcement is allowed to make the law.
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  33. #113
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530

    Default 5 ch RC PWM measurement with pass through

    I made some progress with 5 channel PWM measurement using a single pin. Curently 5 RC channels are being measured using capture on a PIC12f683. Right now, only one channel is being passed through, but it is possible to get a max of 4 channel pass through on this chip. Bruce gave me the idea of measuring all 5 channels on one pin with his remote code learning thread: http://picbasic.co.uk/forum/showthread.php?t=12555

    I need to work on getting channel 1 to be recognized as channel 1. Somehow, I need to check for a low on CCP1 for 3ms or so (between channel 5 and channel1). Anyone got a suggestion on how to do this?

    Right now, you have to restart the circuit a few times to get channel 1 output to be channel 1 input. It sometimes selects channel2,3,4 or 5 (depends when you turn the chip on, and which rise it sees first). But the output now is pretty rock solid, no jitters.

    I tried to label my ASM pretty well, but I need to work on this overall, especially the variables.

    total words used = 275

    http://scalerobotics.com/PWMpassthrough.html

  34. #114
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,541

    Wink

    Hi,

    Ok, it's not PBP ... But it does the trick.

    http://www.rcgroups.com/forums/showthread.php?t=576165

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  35. #115
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530

    Default

    Quote Originally Posted by Acetronics View Post
    Hi,

    Ok, it's not PBP ... But it does the trick.

    http://www.rcgroups.com/forums/showthread.php?t=576165

    Alain
    Thanks Alain (was that for me, or Ken??),

    But I currently am able to encode 1 channel while decoding 5 channels with the below code:

    http://scalerobotics.com/PWMpassthrough.html

    And soon should be able to add 3 outputs, and have 4 encoded channels out, while decoding 5 channels in with the pic12f683 (and 3 diodes).

    But, what I can't get my head around is how to ensure the CCP1 interrupt starts the first time on RC channel 1 (first pulse). It needs to look for a low of 3ms or so, to ensure channel 1 is looking at channel 1.

    Oh .... and I need to do this in ASM.

    Thanks for any help you can offer.
    Last edited by ScaleRobotics; - 9th February 2010 at 20:20.

  36. #116
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,541

    Wink

    Hi,

    Sorry ... I didn't verify the link ... ( Xtal wrote both enc and dec ...)

    those ones are real decoders

    Alain
    Attached Files Attached Files
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  37. #117
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530

    Default

    Thank you very much Alain, just what I was looking for!

    Need to see how they do their "sync gap", but I notice he has a number of other enhancements as well ... interesting.

    Walter
    Last edited by ScaleRobotics; - 9th February 2010 at 23:28.

  38. #118
    Join Date
    Nov 2009
    Location
    Fitchburg, Mass
    Posts
    483

    Talking Been Preoccupied

    Thanks everyone for working on the RC PWM problems.

    Meanwhile I have built a autonomous toy car from the ideas voiced by fritsl in Lets Built Robots.

    The DPDT switches work. I have two separate battery packs. The power for the servo and the wheels shares nothing with the power for the PIC and other logic. Not even the ground circuit! This should keep the noise down.

    I am using the LED's on the PICkit2 to help debug. At least I can know which routines have been visited. I wish I could figure out a way to know what are in my variables. The USB programmer can read and write all memory locations. Where do I read about real time debugging?

    Oh, yes, my new PIC16F887 book arrived via air mail at the Fitchburg, MA Post Office. It is published by MIKROELEKTRONIKA d.o.o in Belgrade, Serbia. How small the world has become.

  39. #119
    Join Date
    Nov 2009
    Location
    Fitchburg, Mass
    Posts
    483

    Thumbs down Setting break points??

    That's the word I have been looking for.

    Is there a mechanism in PBP for setting break points.

    Once that is done, is there an easy way using PICkit 2 Programmer to read the contents of a particular register?

    Ken

  40. #120
    Join Date
    Nov 2009
    Location
    Fitchburg, Mass
    Posts
    483

    Default They talk about using MPLAB IDE

    I see in the PICkit 2 Programmer HELP menu discussion of the Debugger tool. Part of MPLAB IDE.

    Trouble is, the programmer in MPLAB seems to not get along with the programmer in PICkit 2. I have not been able to make hide nor hair of MPLAB IDE. I have been using Microcode Studio PBP and PICkit 2 programmer.

    What am I missing?

    KEn

Similar Threads

  1. PBP Book
    By Bruce in forum Off Topic
    Replies: 81
    Last Post: - 9th June 2010, 10:37
  2. PBP Extensions, What are they?
    By PJALM in forum PBP Extensions
    Replies: 8
    Last Post: - 12th August 2006, 21:03
  3. Compiler differences between PBP 2.33 & 2.46
    By nikopolis in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd May 2006, 19:01
  4. Newby- PBP wont compile for 18F (MPLAB)
    By jd76duke in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th December 2005, 00:30
  5. Making PBP code more modular
    By forgie in forum General
    Replies: 30
    Last Post: - 25th October 2005, 16:24

Members who have read this thread : 6

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts