The worst programmer ever to grace this forum - ME!


Closed Thread
Results 1 to 40 of 50

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    _MCLRE_OFF
    ???
    I do not have the board you have, just maybe..
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    _MCLRE_OFF
    ???
    I do not have the board you have, just maybe..
    BINGO! That was it!!! Many thanks to you all!!

    For the record, anyone else with a PICkit 2 board (with a PIC16F690) .....to save you hours of puzzlement...

    In your C:\PBP\16F690.INC , comment out this one line (thanks to Bruce)...

    ; __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF

    Put all of the following code at the top of your PICBASIC programming window (thanks to mackrackit for the _MCLRE_OFF tip)...

    @MyConfig = _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON
    @MyConfig = MyConfig & _MCLRE_OFF & _BOR_OFF
    @ __config MyConfig

    DEFINE OSC 4

    i var byte

    ANSEL=0 ' all digital
    ANSELH=0 ' analog module disabled
    CM1CON0=0
    CM2CON0=0
    PortC = 0
    TRISC = 0



    And if you have - like I have - a burning desire to see your board's LEDs light in sequence, add this bit of code (thanks to Joe.S)...

    main:
    portc = 0
    pause 500
    for i = 1 to 15; step -1
    portC = i
    i=i << 1
    pause 250
    next i
    goto main
    end



    What's a beginner to do?!!! Most of this was (is!) double dutch....a what with a day & a half's effort just to get LEDs lit with the simplest of basic code....I think my programming interest is going to wane very fast!.

    Now to my main intention, a simple PIC based 'pulse counter' program for a coil winder.

    If your interested, you can read about what I'm trying to achieve here ....

    http://www.electro-tech-online.com/m...am-needed.html

    (you can see my appeal for the simple PIC program didn't get much of a response, hence me having to darken this forum's doorstep and try to figure it all out myself!)
    Last edited by HankMcSpank; - 15th March 2009 at 01:08.

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Huh, that's funny, I copy pasted that from MCS on my computer, and it works splendidly with MCLRE_ON, I can reset MCLRE on the programmer using the little check box and that works too.<br>
    Glad Dave got you going !
    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
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  4. #4
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Just got hit with the next 'gotcha'!

    I was trying to get an LED to light up when the button on my low pin count was pressed - just spent ages trying to figure out why the LED wouldn't light. A check with my voltmeter revealed no matter code I tried, RA3 was always held low, a bit of Googling revealed this...

    http://www.microchip.com/forums/tm.aspx?m=270347


    F: Pushbutton doesn't work with Low Pin Count (LPC) or 28-Pin Demo Boards
    The pushbutton cannot be used on these demo boards when debugging or programming and powering them from the MPLAB IDE. The pushbutton switch is connected to the input pin that is shared with the nMCLR/VPP pin. When Debugging, this pin must be used as nMCLR and cannot be used as an input pin. When programming and leaving the PICkit 2 connected to the Demo Board to power it, the MPLAB IDE always maintains a valid output state on a programmer's nMCLR/VPP pin which prevents the switch from changing the signal value. Use the PICkit 2 Programmer software to allow the switch to be used.


    It seems I now have to assemble, & then fire up PICKit 2 to wrtie the hex to the PIC (button works as it should then).

    Mindboggling for a beginner like me, ie that there should be so many 'enviromental' hurdles to get over, when all I want is to learn the most simple of code!
    Last edited by HankMcSpank; - 15th March 2009 at 10:03.

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


    Did you find this post helpful? Yes | No

    Default

    I will suggest you pick up a cheap bread board or two and a hand full of LEDs, resistors, caps etc. The demo boards are nice I guess, but you can not do a whole lot with them other than what they were designed to do.

    As far as the coil winding project goes. A switch on a cam or some other part will work. Every revolution the switch is "bumped" from low to high. Every time the switch is bumped a variable is incremented.

    If it is not running real fast interrupts will not be needed.
    Code:
    LOOP:
    IF SWITCH = 1 THEN
    WRAP = WRAP + 1
    GOTO LOOP
    That is the basics. Add a serial or LCD to display the value. Add
    IF WRAP = X THEN GOTO STOP ???

    Let us know...
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    I will suggest you pick up a cheap bread board or two and a hand full of LEDs, resistors, caps etc. The demo boards are nice I guess, but you can not do a whole lot with them other than what they were designed to do.

    As far as the coil winding project goes. A switch on a cam or some other part will work. Every revolution the switch is "bumped" from low to high. Every time the switch is bumped a variable is incremented.

    If it is not running real fast interrupts will not be needed.
    Code:
    LOOP:
    IF SWITCH = 1 THEN
    WRAP = WRAP + 1
    GOTO LOOP
    That is the basics. Add a serial or LCD to display the value. Add
    IF WRAP = X THEN GOTO STOP ???

    Let us know...
    Whilst I was sold on the concept of the ease of use of the Microchip low pin count board, (esp to get me some simple quick & dirty IO) I'm now very rapidly seeing the shortcomings!

    As it goes I have, breadboard & plenty of components...I'll be using all that in earnest, once I've nailed the basics here (no pun intended).

    Re the coil winder. I'm using an old DC cooling fan with a drill chuck hot glued to its centre ( http://img25.imageshack.us/img25/2717/workshopjd8.jpg - ugly but fulfills a need!)....this drill chuck will hold the 'solenoid core' while to copper wire is wound onto it. On this fan will be 7 or so magnets, each in turn closing a magnetic reed switch as the motor turns (I'd imagine the maximum speed the fan will be turning at for this project will be about 200RPM I've made a simple PWM circuit to control the speed of the fan).

    Where the PIC comes into the equation, is that it will count the pulses from the fan motor. For every 'X' pulses it receives from fan motor's reed switch, the PIC will send one short pulse onwards to a UCN5804 stepper motor IC. It's essentially a pulse counter/divider ...for ever x pulses received, output one pulse.

    The UCN5804 feeds a small stepper motor - on its shaft is a bit of threaded nylon rod - it's over this threaded rod that the copper wire feeds onto the solenoid core (this youtube video illustrates what I'm trying to achieve well - (from about 27 seconds in).

    The whole point of this is to have my wire neatly wound onto the solenoid. Since I know the diameter of the copper wire (0.15mm), & I know the pitch of the nylon rod's thread feeding the wire (1mm), it's just a fairly simple calculation. therefore for every turn of the main DC fan, I need the stepper motor threaded rod traverse the wire 0.15mm. It's a 7.5deg stepper, therefore each step of the 1mm pitch threaded rod will traverse the copper wire 0.0208mm, therefore to move the wire 0.15mm, some 7.2 steps needed are to the stepper for every turn of the main fan (since there's no such thing as 0.2 of a pulse I'll be rounding it down to 7!)

    To nail this project I need to...

    1. Sort out all the idiosyncracies of getting my PIC programming enviroment set up for the PIC16F690 - check! (thanks to here!)
    2. Lean how to set a PIC output pin high - check!
    3. Learn how to check a PIC input pin (to see if a switch has closed) - check!
    4. Learn how to setup a few 'count' variables, get them incrementing (& check 'em)....acting whenever the counts have been met - still to do!
    5. Learn how to output a pulse - still to do.

    I'll also need to figure out some form of debounce (I may end up using a monostable chip to do this)

    Thanks for your suggestion on how to approach this...I'll have a play with your lines to see if I can get the switch on my low pin count board to act as the reed switch & one of the LEDs as the stepper chip feed....ie after 7 presses of the board's button, make an LED turn on.
    Last edited by HankMcSpank; - 15th March 2009 at 13:51.

  7. #7


    Did you find this post helpful? Yes | No

    Default

    do the debounce in software. (short pause) or if it's off to do something else once triggered, you may not even need debounce..

    you can search for debounce examples from here http://www.picbasic.co.uk/forum/showthread.php?t=4751

Similar Threads

  1. Melabs U2 Programmer Command Line Options
    By Robert Wells in forum General
    Replies: 5
    Last Post: - 3rd July 2009, 02:11
  2. problems with USB programmer
    By malc-c in forum General
    Replies: 7
    Last Post: - 10th May 2007, 20:14
  3. USB programmer problems
    By uiucee2003 in forum USB
    Replies: 2
    Last Post: - 15th August 2006, 23:47
  4. General Programmer Questions
    By mslaney in forum General
    Replies: 1
    Last Post: - 17th December 2004, 18:16

Members who have read this thread : 0

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