• AVR Freaks

Hot!Bonehead Help v2.1

Author
jweir43
New Member
  • Total Posts : 20
  • Reward points : 0
  • Joined: 2019/05/22 13:43:05
  • Location: Grass Valley, 60 miles north of Sacramento
  • Status: offline
2019/06/18 13:53:10 (permalink)
0

Bonehead Help v2.1

First, thanks to all of you that pushed me along on v2.0 where we couldn't even find the chip.  It turned out to be an "undocumented feature" of MELAB X IPE v2.15 and how you select the chip.  Now it is programming, and I can see my hex code in the program window in View.  However, it is NOT changing the CONFIG register and it is NOT blinking the LED (nor does an o'scope on the output pin show any outputs at all.)  If you wouldn't mind taking a look at my code and making suggestions as to what I'm doing wrong I'd appreciate it.  jw
 
' Name : blinkjw.bas
' Compiler : PICBASIC PRO Compiler 3.1
' Assembler : MPLAB X IPE v5.15
' Target PIC : 12F609
' Hardware : Lab Protoboard
' Oscillator : Internal 4 MHz.
' Keywords : LED
' Description : PICBASIC PRO program to blink an LED connected
' to PORTA.2 about once a second.
' PORTA.2 is pin 5 of the 12F609.
#CONFIG
;
; __config _FOSC_INTOSCIO
; __config _WDT_ON
; __config _MCLRE_ON
; __config _IOSCFS4
; __config _CP_OFF
;
; #ENDCONFIG
TRISA = %00001000
LED var PORTA.2 ' Alias PORTA.2 to LED
mainloop:
High LED ' Turn on LED connected to PORTA.2
Pause 500 ' Delay for .5 seconds
Low LED ' Turn off LED connected to PORTA.2
Pause 500 ' Delay for .5 seconds
Goto mainloop ' Go back to loop and blink LED forever
End
 
Thanks,
Jim

The Titanic was built by expert engineers and a reputable company.  The Ark was built by amateurs at home.
#1

7 Replies Related Threads

    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11338
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: Bonehead Help v2.1 2019/06/18 14:25:26 (permalink)
    +1 (1)
    You have the config settings commented out.
     
    #2
    jweir43
    New Member
    • Total Posts : 20
    • Reward points : 0
    • Joined: 2019/05/22 13:43:05
    • Location: Grass Valley, 60 miles north of Sacramento
    • Status: offline
    Re: Bonehead Help v2.1 2019/06/18 15:06:23 (permalink)
    0
    jtemples
    You have the config settings commented out.
     

     
    You are exactly correct.  I'm still feeling my way around the command structure of this dialect of BASIC and at one point I thought I remembered the (;) semicolon as the line continuation command.  T'ain't so, Joe.
     
    Blinkie light now works just fine.  It has only taken me three weeks to get there.  
     
    Thanks for the help...
    Jim

    The Titanic was built by expert engineers and a reputable company.  The Ark was built by amateurs at home.
    #3
    mpgmike
    Super Member
    • Total Posts : 281
    • Reward points : 0
    • Joined: 2014/01/23 17:27:06
    • Location: NJ
    • Status: offline
    Re: Bonehead Help v2.1 2019/06/18 15:53:25 (permalink)
    0
    YYYAAAAAAAAAHHHHHHH!!!!!  Congratulations!!!!!!  Doesn't it feel good?!?!?!?!?  You conquered!  Now to get that stupid piece of silicon doing what you REALLY wanted to begin with.  I'm glad you stuck with it, Jim.  You now know enough to make meaningful things happen.

    I don't need the world to know my name, but I want to live a life so all my great-grandchildren proudly remember me.
    #4
    jweir43
    New Member
    • Total Posts : 20
    • Reward points : 0
    • Joined: 2019/05/22 13:43:05
    • Location: Grass Valley, 60 miles north of Sacramento
    • Status: offline
    Re: Bonehead Help v2.1 2019/06/18 16:16:56 (permalink)
    0
    mpgmike
    YYYAAAAAAAAAHHHHHHH!!!!!  Congratulations!!!!!!  Doesn't it feel good?!?!?!?!?  You conquered!  Now to get that stupid piece of silicon doing what you REALLY wanted to begin with.  I'm glad you stuck with it, Jim.  You now know enough to make meaningful things happen.


    Oh, yeah.  The first project is easy programming but a witch-kitty for space.  There is a model railroad switch line that needs an H-bridge to reverse the "sense" of the switch -- one way for the main line and another way for the branch line.  BUT it needs a half-amp pulse of no more than 500 milliseconds to go main or branch.  Easy peasy with a bipolar transistor bridge and the uC doing the logic and timing.  Pretty simple but it has to fit in one square inch.
     
    The second one has all the room in the world but a witch-kitty for function.  Seven analog inputs that need to be switched between headphone and speaker power amplifiers plus switch a microphone between two transmitters, switch a digital voice recorder on and off, and a few more goodies.  But I think I've got a handle on how it can be implemented with three devices plus the power amps (sort of my wheelhouse).
     
    And thanks to you I now know how to do it all.  Bless you.
     
    Jim

    The Titanic was built by expert engineers and a reputable company.  The Ark was built by amateurs at home.
    #5
    ric
    Super Member
    • Total Posts : 23846
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Bonehead Help v2.1 2019/06/18 16:28:59 (permalink)
    0
    When you do your H bridge, you will nbeed to be very mindful of "read-modify-write" effects on the output pins.
    This will bite you when you change two pins in the same port in consecutive instructions.
    These old PICs don't have "LAT" registers to avoid this problem.
    You either need to make sure you have a small delay between each pin write, or structure your code to keep a copy of the PORT contents in a variable, manipulate bits in the copy, and only ever write to the entire port.
     
    I bring this up because this sort of error on an H bridge could result in you turning on both the upper and lower transistors at the same time, which can have a rapid affect on your power fuse ...
     
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #6
    jweir43
    New Member
    • Total Posts : 20
    • Reward points : 0
    • Joined: 2019/05/22 13:43:05
    • Location: Grass Valley, 60 miles north of Sacramento
    • Status: offline
    Re: Bonehead Help v2.1 2019/06/18 21:03:25 (permalink)
    0
    ric
    When you do your H bridge, you will need to be very mindful of "read-modify-write" effects on the output pins.
    This will bite you when you change two pins in the same port in consecutive instructions.

     
    Yeah, when I was in this h-bridge game for the first time 50 years ago, I let both A and B go positive for a few milliseconds ... POOF went the transistor (which at the time went for about $10 in today's dollars).  Boss wasn't happy.
     
    The easy way, since this is a pulse application (the switch goes main to branch or back with a simple half-second pulse on either A or B and then no current flows in the bridge for minutes, hours, or days) is to apply the pulse, then turn both A and B outputs to zero.  Then the next time through the operation you turn on EITHER A OR B for half a second and then return both of them to zero.  Next time it is B or A, and we just toggle back and forth between main and branch lines.
     
    No, both A and B both on, microseconds to milliseconds is **not** a good idea.
     
    Thanks,
     
    Jim

    The Titanic was built by expert engineers and a reputable company.  The Ark was built by amateurs at home.
    #7
    jweir43
    New Member
    • Total Posts : 20
    • Reward points : 0
    • Joined: 2019/05/22 13:43:05
    • Location: Grass Valley, 60 miles north of Sacramento
    • Status: offline
    Re: Bonehead Help v2.1 2019/06/18 21:05:52 (permalink)
    0
    q
     

    The Titanic was built by expert engineers and a reputable company.  The Ark was built by amateurs at home.
    #8
    Jump to:
    © 2019 APG vNext Commercial Version 4.5