Weird PIC & PICAXE Stuff
& Some Notes on their Use
Weird & Unusual findings about PIC Basic PRO

revised 12-07-11  d. bodnar

NOTE:  These are just random notes that I put together as problems with PICs (&  PIC Basic Pro) and PICAXE chips.  They are not meant to be complete or to mean anything to anyone but the author!

 

 

  1. Module - The problem with copying a good file (8.1x-xp) to another chip appears to get resolved when NEW chips are used - otherwise you can get switch motor #2 resets or phantom reed switch hits from #4 (usually) - very strange!
  2. On Module 16F88 I had to insert a pause 200 at the very top to allow reprogramming with ICSP due to pins 12 and 13 being used as outputs - see:

http://www.microchip.com/forums/m458450-print.aspx

make sure it goes AFTER DEFINE OSC 8 or whatever speed setting are used

or use PAUSE 8 before oscillator and pause 1200 after seems to work

MAKE sure you remove wire to pin 4 (from other laser board) to program!

  1. BARC - program from XP mode - will not work with PWM properly from Win7!
    1. here are the settings

       
  1. Can't believe this but the programmer was at fault on all of the 12F683 issues with HPWM on two channels & inputs not working with WPU - here is the note I found on the web:
    Problem solved!

    Your download produced the same symptoms as my program, but when I read it back it certainly didn't show INTOSCIO - from memory it might have been INTRC also MCLR was ON. Obviously not picking up the correct config settings as you suspected.

    I had a lucky flash of inspiration and in Microcode went to Options||More Options and pressed Set Options to Defaults.

    Immediately all came good and the PIC programmed perfectly.

    So thank you (and thanks to the others) for your help and I can get back to my PCB testing.
  2. Could not get reading inputs on 12F683 working from Win 7 but OK from XP - program was Crossing_Signal_IR_1v1.5.bas under emil
  3.  More weird stuff with 16F684 / 688 - from Win 7 cannot get port a WPU to work - compiled in XP and it worked A-OK - moved hex file to Win7 and it still did not work even with matched configuration - tried from both programmers!  Very strange, indeed!
  4. 16F688 working with Crossing Controller 2.2 – cannot get it to program with both weak pullups and dual PWM for ditch lights.  Tried XP mode, XP laptop and Win 7 PC – same results.

Finally read the code from one good chip and saved it to disk and used that to reprogram with the settings below – HP Laptop /w USB programmer
crossingController22-readfromworking.hex

 

  1. On new compiler / assembler 16f88 and maybe others - changes CON value for PWM out pin from 2 to 1 (pin 6)
  2. HPWM problem on 16F88 - had to set CCP Multiplexed With to BR0 in programmer to get it to work - may create other troubles in speedometer
  3. TO PROGRAM FOR SPEEDOMETER
    1. use virtual XP running old compiler - it will take the @DEVICE data
    2. user version 3.2b (modified to 3.3a without wireless & such)
    3. capture serial port and user serial programmer
    4. make sure RB0 is selected.
    5. doesn't need any changes to OSC
    6. disable wireless for most users
  4. Speedo on old IBM laptop - save file locally to avoid out of memory error
    1. remove @DEVICE & user MPASM Windows interface
    2. seems to work!
  5. make sure you set fuses correctly & manually in programmer
  6. Tantalum cap necessary across power pins on 16F88 for ICSP programming
  7. 16F88 - to use pins 15 & 16 (a6 a7) as outputs must set OSCILLATOR = INTRC in programmer
  8. 16F88 - got the 16f88.inc in PBP-260a to take this line to disable reset and use pin 4 as input pin

 

        __config _CONFIG1, _HS_OSC & _WDT_ON & _LVP_OFF & _CP_OFF & _MCLR_OFF

only added & _MCLR_OFF

could not get it to work with internal oscillator???!!!???

  1. This works to keep the config settings between programming sessions
    Why does the programmer software reset my configuration settings every time I program?


    If you have selected both the "Reread File Before Programming" and "Update Configuration From File" options, meProg will update the configuration from the HEX file automatically before programming. To make your configuration changes stick, either save the HEX file with the new configuration, or uncheck one of the options above.
  2.  16F88 (and others?) only do hardware interrupt on portb.0 - same pin as HMWP!
  3. to get PWM to work on two pins on a 16F683 must set as follows (see Crossing Controller program

 

'allows use of two pins -one up/one down (pins 5/6)

CCP1CON = %10001100 

Test:'works on pins 5 & 6

ADCIN 4, Pauze

temp2=1

        debug 10,13, "PIN # = ",#temp2 ,10,13 ,10,13

        for temp1=1 to 255 step 10  

            debug "t1 ",#temp1,"   "

            hpwm temp2, temp1, 255

        next temp1

        debug 10,13 ,10,13

 

     for temp1=255 to 1 step -10

        debug "t1 ",#temp1,"   "

        hpwm temp2, temp1, 255

     next temp1

goto test

  1. to turn PWM off and use pins as outputs CCP1CON=%10000000 - you can turn HPWM on/off at will!
  2.  
  3.  Need to set Fuses like this to get it working on 16F88 AC Trolley

 

maybe this one

 

 

 

This setup worked with + 5 from programmer & after getting that done with 5 volts from 7805 - very strange, indeed!

RB0 must be selected or motor will not work!

 

  1.  When programming 16F88 on AC-trolley SMT circuit put 5volts from programmer (no other power) to the LED side of the power indicator's 500 ohm current limiting resistor and it programmed - not when attached right to the 5 volt pin on 7805.  STRANGE
  2. when programming 12f683 for beacon this setting worked - strange that I had to reboot to get it to work again - very frustrating as I couldn't get the IR PWM for Sony codes to work for several hours!
  3.  
  4. Timing may be the issue with IR Beacon - with serout it worked, without it stopped - added a pause 100 and it works with serout removed....  it would be nice if that was all it was!
  5. Random: 

use DIG function to get #s from 0 to 9 or 0-99 (as below)

GetRandom2:             
debug 10,13,"random "
for temp=1 to 100
  random rndmtemp  'reset seed
  temp2=rndmtemp dig 2
  temp2=temp2*10
  temp2=temp2+ rndmtemp dig 1
  debug "  ",#temp2
pause 10
next temp
return

  1.  notes on migrating from 16F88 to 16F1827 (new chip on 18M2 PICAXE) in PicBasic Pro  http://www.picbasic.co.uk/forum/showthread.php?t=12739
  2. when using 16F683 & IRIn & Servo with pulses  remove DEBUGs to get timing right otherwise servos jitter a great deal
  3. good code for servo:

MoveServos:

servo1pin = 1           ' Start servo pulse

Pauseus 300 + temp

servo1pin = 0           ' End servo pulse

Pause 16                ' Servo update rate about 60Hz

servo2pin = 1          ' Start servo pulse

Pauseus 300 + temp3

servo2pin = 0           ' End servo pulse

Pause 16                ' Servo update rate about 60Hz

return

  1.  MIN MAX test code

NumIn            var word

NumOut           var word

MINimum          var word

MAXimum          var word

 

debug 10,13,10,13,"Test of MIN MAX functions",10,13,10,13

 

MINimum= 200

MAXimum= 1000

 

For NumIn = 100 To 1299 step 30    

       NumOut=NumIn min MAXimum max MINimum

       Debug "NumIn, NumOut = ",#NumIn," ",#NumOut,10,13

Next NumIn

 

end

 

 

  1.   Speedometer - 16f88 - problem with ICSP, but works with newer programmer and version 3.2b using no fuses in program and these settings in programmer:

 

  1.  
  2. XP on Win 7 gives out of memory error when file name is too long!
  3.   Got RTC board to work under Win7 - version 2.1x - problem was due to a bad chip!
    not true - serial didn't work - used XP under Win7 with the setup below

seems to be A-OK - version 2.2

  1.