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

revised 12-28-13  d. bodnar
08-15-14

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!

Older version

0.  8-9-14 - got Speedometer to program from Win8.1 using USB programmer - set to ccp=rb0 - used ICSP - sometimes have to program several times in rapid succession to get it to start
Also working from older Dell desktop with same melabs programmer version & USB programmer

Make sure MCLR is set to INPUT and must use ME Labs programmer software version 4.2

  1. on AC trolley (internal using Aristo socket) needed to add
    OSCCON = %01100111    'MUST BE USED to set clock speed =$67
    to get it to work at all with newest programmer software -----12-29-13
    ALSO needed pauses before & after OSC 8 (see info below)
  2. VMUSIC2 and VMUSIC3 - to set volume to maximum use   
        serout serial_out, 2, ["VSV ",0, 13]:pause 100
    not  
    serout serial_out, 2, ["VSV 0 " 13]:pause 100     as shown on some web sites 
  3. on 16f684 needed  
    ansel=0 'allows you to use pins as digital rather than analog                to get pin 11 to be input with WPU
  4. VMUSIC2 serial from pin 9 interfered with by high or low or toggle led commands - had to change serial out pin from 9 to 6 to get VMUSIC2 to work.... very, very strange!
  5. 16F684 - pins 10 and 12 don't work as outputs without    cmcon0=7 'allows you to use pins as digital rather than analog 
    may also need     ansel=0
  6. New Module Controller - set as below - important setting for PWM is CCP2 Multiplexed with RB3!

  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 (SPEEDOMETER, too!!!) 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. New compiler needs define debug and such to be in UPPER CASE!  Old one took lower case!
  2. BARC and  CHP Timer - discovered that pin 7 as an input pin (button) needed a 1K for pull low to go to 0 rather than the 10K that I had been using  ---- why did this change?  Strange!
  3. BARC - program from XP mode - will not work with PWM properly from Win7!
    1. here are the settings

       

    for BARC & i7 and USB programmer -  use these setting & change constant for HPWM from 2 to 1

    Got BARC somewhat working from i7 Win 8 with these settings- note that MCLR is input pin!  May be the same problem with the 10K vs 1K pull up resistors - I am using a 10K and it may need to be 1K!

    also helps to press button by LEDs when starting to program!

  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 16f684 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 16f684 & 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. Speedometer Observations 7-18-13    
    Tried to program new Speedometer with no luck till I dug out the old XP from IBM with serial port - used serial programmer (no ICSP) and programmed using RB0 with version 3.3b from the laptop. 
    Before that the sensors didn't work (showed all off when plugged in)
    Very frustrating!  
  2. UPDATE= purchased upgrade for both programmer & complier and it now works from Windows 8, but not with ICSP - yea!
  3. 16F88 - experiment sending serial from PIC to Arduino -

      To get pins 15 & 16 to work had to change oscillator to INTRC before programming

     

  4. PIC16F88 on Speedometer - PWM not working from Windows 8 PC

    had some success today - compiled on XP computer and programmed using serial programmer on Windows 8 computer using the HEX file from the XP computer AND the Meprog folder from the XP machine (put it in the Shared_Stuff directory - Seems A-OK as PWM is working --- unfortunately the file generated by the Win 8 version of the compiler does not work (No PWM) but the one from the xp compile does.... strange!

Just retested and the file from old PC (XP) does work from both installations of serial programmer.  Appears that the compiler is at fault