Quantcast
Channel: MEL PICBASIC Forum
Viewing all 4787 articles
Browse latest View live

Converting dec to hex, no built-in support?

$
0
0
I need to convert decimal value to hex, to send it to RTC. Seems like PBP has no built in convertors?

I have hex values such as rtcmin, rtcsec, rtchour and so on.
I have a decimal variable which changes on button press. Have to convert it to hex, but can't find proper statement.
Of course I can do it by hand, like this

Code:

IF TIMEVAR=10 THEN RTCMIN=$10
IF TIMEVAR=11 THEN RTCMIN=$11

and so on, but just to set minutes, I will need 60 lines of code!

Why statements like RTCMIN=HEX TIMEVAR or RTCMIN=$TIMEVAR do not work?

OSCCON=$60 Help Please 16F628

$
0
0
Hi All

Attempting to set up a serial comms unit to control a MP3 player.

But issues with compiling this bit:-

Code:

DEFINE OSC 4        'Set oscillator in MHz
            'OSCCON = $60    '4 Megs Xtal

            TRISA=0        'Port A all outputs
            TRISB=%00001100 'Make RB3 and RB4 in-puts
            'OPTION_REG.7=0 'Enable internal pull-ups
            CMCON=7        'No Analogs

I have an external HS Crystal (4Megs) Just not understanding what needs to be here or not here to make it compile ok.
Do I need the OSCCON
Do I need the Define OSC 4

I know the issue is the red text ????

BR
Andy

Thank you for help

Trouble Receiving Serial on PIC16F690

$
0
0
Hi—

I’ve been stumped with a problem for the last two days. I am using a PIC16F690 and trying to do serial communication with it. I am able to successfully send serial out using both HSEROUT and SEROUT, but I cannot get either HSERIN or SERIN to work. I have checked the logic level of my USB to serial adapter using my oscilloscope and it is sending 5V levels into the designated RX pin, but no matter what I try it does not accept any serial characters. I’ve tried various baud rates and T vs N (when I was trying to see if I had more luck with SERIN over HSERIN) just in case; no luck. I’ve also tried the same code (using only the SERIN command) on a PIC16F1507; again, SEROUT works but not SERIN.

I studied the data sheets for these parts and I can’t find anything that I have missed… is there some peculiarity about these chips that I may have missed?

I pasted below one of the HSERIN tests I tried with the F690, based on ME Labs' HSERIN/HSEROUT demo code. In this particular version I commented out their DEFINE HSER_RCSTA 90h and set the SPEN & CREN bits explicitly, just in case. But even without the explicit commands to set those bits and leaving the DEFINE HSER_RCSTA 90h alone as per the example, the serial receiving still doesn’t work. It does send the “Hello World” correctly.

Any suggestions or tips would be very welcome!

Thanks—

—Alan


Include "modedefs.bas"
DEFINE OSC 8 'define the clock speed so BASIC knows
OSCCON = $FF

ADCON1 = 7
RCSTA.7 = 1 'SPEN = 1
RCSTA.4 = 1 'CREN = 1
TXSTA.4 = 0 'SYNC = 0

' Set receive register to receiver enabled
' DEFINE HSER_RCSTA 90h
' Set transmit register to transmitter enabled
DEFINE HSER_TXSTA 20h
' Set baud rate
DEFINE HSER_BAUD 9600

char Var byte ' Storage for serial character

start:
Hserout ["Hello World", 13, 10] ' Send text followed by carriage return and linefeed
low portc.5 ‘LED on
pause 250
high portc.5 ‘LED off

mainloop:
Hserin 10000, start, [char] ' Get a char from serial port
Hserout [char] ' Send char out serial port
Goto mainloop ' Do it all over again

End

ADC input signal filter selection

$
0
0
HI Folks, I'm brand new to the forum and really appreciate your support- Thank You!. I have a question; I recently designed an A/D circuit which worked wonderfully on my breadboard and also when I transitioned/soldered the hardware to a small prototype board. When I moved the same prototype board out to the truck and put it into service, the display values were jittery and jumped around quite a bit. The degree of variation was its worst at the very lowest end of the values and almost completely disappeared at the upper ranges. This seemed liked "signal noise" to me. Very unscientific conclusion. After doing some research I decided to add a larger capacitor (from 47 picofarad to 22 microfarad) on the signal line.

My question is- is there a simple way to size a series resistor and capacitor for a typical A/D input for folks without an advanced degree in circuit design? Random selection seemed to work in this case but I'm hoping for some more scientific help. I read through Microchip's AN693 white paper and also looked at guidance on a low pass RC filters and downloaded Microchip's Filter Lab App. But none of that helped much. One of my goals is also to minimize space and components. Is there an easier or simpler starting point or some basic guidance on ways to select Resistor & Capacitor values for signal conditioning?

Thanks in advance for any help and guidance and for your general support-
Mark

Need help with Path new install

$
0
0
Im having a path problem mpasmwin cannot be found some place there was a sheet explaining this and I cannot find it

Executing: "C:\Program Files (x86)\PBP3\PBPX.EXE" -ampasmwin -k# -p16F876A "6633-AMD-HO.bas"
PICBASIC PRO(TM) Compiler 3.0.8.4, (c) 1998, 2013 microEngineering Labs, Inc.
All Rights Reserved.

ERROR: Unable to execute mpasmwin.Halting build on first failure as requested.
BUILD FAILED: Thu Feb 07 11:58:22 2019

PIC12F1840 & serout2

$
0
0
Hi,
Anyone used the PIC12F1840 with serout2? Any tricks to it? I can't get anything out.

Regards,

Troy

It is Y2K19 but DS18B20PAR+ Returns either 127 or 85 depending on resistor value.

$
0
0
Hello, I'm trying to get this sensor working with PIC16F1519. It is connected to PORTD.1 and MAX7219 display to PORTC. Nothing else. I'm using 4.7k resistor to deliver voltage to it. But it does not works. If I use 4.7k or 5.6k resistor, it will return 127, if I use 2.2k or 10k resistors, it will return 85. I've tried replacing chip, playing with ANSELD and TRISD registers - no luck. I'm using "classic" code from melabs example. What I'm doing wrong?

Code:

;----[16F1519 Hardware Configuration]-------------------------------------------
#IF __PROCESSOR__ = "16F1519"
  #DEFINE MCU_FOUND 1
#CONFIG
cfg1 = _FOSC_INTOSC          ; INTOSC oscillator: I/O function on CLKIN pin
cfg1&= _WDTE_OFF              ; WDT disabled
cfg1&= _PWRTE_OFF            ; PWRT disabled
cfg1&= _MCLRE_OFF            ; MCLR/VPP pin function is MCLR
cfg1&= _CP_OFF                ; Program memory code protection is disabled
cfg1&= _BOREN_OFF            ; Brown-out Reset disabled
cfg1&= _CLKOUTEN_OFF          ; CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin
cfg1&= _IESO_OFF              ; Internal/External Switchover mode is disabled
cfg1&= _FCMEN_OFF            ; Fail-Safe Clock Monitor is disabled
  __CONFIG _CONFIG1, cfg1
cfg2 = _WRT_OFF              ; Write protection off
cfg2&= _VCAPEN_OFF            ; VCAP pin function disabled
cfg2&= _STVREN_ON            ; Stack Overflow or Underflow will cause a Reset
cfg2&= _BORV_LO              ; Brown-out Reset Voltage (Vbor), low trip point selected.
cfg2&= _LPBOR_OFF            ; Low-Power BOR is disabled
cfg2&= _LVP_OFF              ; High-voltage on MCLR/VPP must be used for programming
  __CONFIG _CONFIG2, cfg2
#ENDCONFIG
#ENDIF
;----[Verify Configs have been specified for Selected Processor]----------------
;      Note: Only include this routine once, after all #CONFIG blocks
#IFNDEF MCU_FOUND
  #ERROR "No CONFIGs found for [" + __PROCESSOR__ +"]"
#ENDIF

'****************************************************************
'*  Name    : UNTITLED.BAS                                      *
'*  Author  : [select VIEW...EDITOR OPTIONS]                    *
'*  Notice  : Copyright (c) 2018 [select VIEW...EDITOR OPTIONS] *
'*          : All Rights Reserved                              *
'*  Date    : 11.12.2018                                        *
'*  Version : 1.0                                              *
'*  Notes  :                                                  *
'*          :                                                  *
'****************************************************************
'SERVOCONTROLLER SYSTEM
                       
'init
include "modedefs.bas"
OSCCON = %01111010  'SET INTOSC TO 16MHZ
ANSELC=%00000000
ANSELD=%00000000
TRISC=%00000000 'set PORTC as output all
TRISD=%11111111 'set PORTD as output all
DEFINE OSC 16
dqd var PORTD.1
tvla var word
temperature var word
'DEFINES:
 Clk    Var PORTC.6  ' Data is clocked on rising edge of this pin            mcvane
 Dta  Var PORTC.5  ' Bits are shifted out of this pin          KVITELI
 Load    Var PORTC.4  ' Transfers data to LEDs when Pulsed  lurji
 
 
 'MAX7219 STUFF
    ' ** Declare Constants **
 Decode_Reg  Con 9 ' Decode register, a 1 turns on BCD decoding for each digit.
 Lum_Reg  Con 10 ' Intensity register.
 Scan_Reg Con 11 ' Scan-limit register.
 Switch_Reg Con 12 ' On/Off Register.
 Test_Reg Con 15 ' Test mode register (all digits on, 100% bright)
 Max_Digit Con 4 ' Amount of LED Displays being used.
' ** Declare Variables **
  Counter  Var Word ' Variable used for the Demo Counting routine
 Max_Disp Var Word ' 16-bit value to be displayed by the MAX7219
 Max_Dp  Var Byte ' Digit number to place Decimal point (0-4)
 Register Var Byte ' Pointer to the Internal Registers of the MAX7219
 R_Val  Var Byte ' Data placed in Each Register
 Digit  Var Byte ' Position of individual numbers within MAX_Disp (0-3)
 Position Var Byte ' Position of each LED display (1-4)
 
 ' Turn Off test mode
 Register=Scan_Reg  ' Point to the Scan Register
 R_Val=7    ' send 3, (Four LED Displays 0-3)
 Gosub Transfer  ' Transfer this 16-bit Word to the MAX7219
 Register=Lum_Reg  ' Point to the Luminance Register
 R_Val=1    ' Send 5, (Value for Brightness)
 Gosub Transfer  ' Transfer this 16-bit Word to the MAX7219
 Register=Decode_Reg  ' Point to BCD Decode Register
 R_Val=%00001111 ' Decode the first 8 digits
 Gosub Transfer  ' Transfer this 16-bit Word to the MAX7219
 Register=Switch_Reg  ' Point to the Switch Register
 R_Val=1    ' Set to One, (switches the display ON)
 Gosub Transfer  ' Transfer this 16-bit Word to the MAX7219
 Register=Test_Reg  ' Point to the Test Register
 R_Val=0    ' Reset to Zero, (turns off Test mode)
 Gosub Transfer  ' Transfer this 16-bit Word to the MAX7219

 Max_Dp=0  ' Display number for Decimal Point
REGISTER=8      'display some name
R_VAL=124
GOSUB TRANSFER
REGISTER=7
R_VAL=110
GOSUB TRANSFER
REGISTER=6
R_VAL=120
GOSUB TRANSFER
REGISTER=5
R_VAL=57
GOSUB TRANSFER

TTK:
pause 500
gosub gradus1
max_disp=temperature
GOSUB DISPLAY
GOTO TTK



GRADUS1:
        OWOUT DQD, 1, [$CC, $44] ' Start temperature conversion
        pause 750
        OWOUT DQD, 1, [$CC, $BE]        ' Read the temperature
        OWIN DQD, 0, [temperature.LOWBYTE, temperature.HIGHBYTE]
        temperature = temperature */ 1600
        TEMPERATURE=TEMPERATURE/100

 
return
 
Display:
 Digit=0      ' Start at Digit 0 of Max_Disp Variable
 For Position=4 to 1 step -1  ' Start at Farthest Right of Display 
 Register=5-Position    ' Place Position into Register
 R_Val=Max_Disp Dig Digit  ' Extract the individual numbers from Max_Disp 
 If Max_Disp<10 and Position=3 then R_Val=15 ' Zero Suppression for the second digit
 If Max_Disp<100 and Position=2 then R_Val=15 ' Zero Suppression for the Third digit
 If Max_Disp<1000 and Position=1 then R_Val=15 ' Zero Suppression for the Forth digit
 If Max_Disp<10000 and Position=0 then R_Val=15 ' Zero Suppression for the Fifth digit
 If Digit=Max_Dp then R_Val.7=1  ' Place the decimal point, held in Max_DP
 Gosub Transfer    ' Transfer the 16-bit Word to the MAX7219
 If Digit>=3 then Digit=0  ' We only need the first four digits
 Digit=Digit+1    ' Point to next Digit within Max_Disp
 Next Position    ' Close the Loop
 Return
' Send a 16-bit word to the MAX7219
Transfer:
  Shiftout Dta,Clk,msbfirst,[Register,R_Val] ' Shift Out the Register first, then the data
 High Load    ' The data is now acted upon
 PAUSEUS 100
@ Nop
@ Nop    ' A small delay to ensure correct clocking times
 Low Load    ' Disable the MAX7219
 Return    ' Exit from Subroutine

PORTA.5 not responding on 16F18346??

$
0
0
Bizarre behavior that I cannot explain on the PIC16F18346... any suggestions would be more than welcome.

Simply put, MYLED does NOT flash, but the output from the pin remains LOW.
meanwhile, MYLED1 flashes like it's supposed to.

STUMPED...

Code:

'  PORT/ADCON SETTINGS
ADCON0=%00010001 'A/D control
ADCON1=%11110000 '(RC conversion clock, right justified 10-bit result)
'---------------------------------------------------------------
PORTA=%00000000 'assign initial output values so they don't show up randomized
TRISA=%011101  'assign DDRA (1=in, 0=out)
ANSELA=%010000  'PA.4 analog mode
'WPUA.3=1        'enable WPU on pushbutton input (later use)
'WPUA.2=1        'enable WPU (later use)
'---------------------------------------------------------------
PORTB=%00000000 'assign initial output values so they don't show up randomized
TRISB=%11100000 'assign DDRB (1=in, 0=out)
ANSELB=%00000000 'all in digital mode
'WPUB=%11000000  'WPU for future
'---------------------------------------------------------------
PORTC=%00000000
TRISC=%00000000
ANSELC=%00000000
'*******************************************************************************
'
'  DEFINES
define OSC 32
DEFINE ADC_CLOCK 2 'use separate RC conversion clock
DEFINE ADC_BITS 10 ' Set number of bits in result
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS
define WRITE_INT 1
'the following must be used for this chip to disable default settings (for PWM enabled)
DEFINE CCP1_REG 0  'channel-1 unused
DEFINE CCP1_BIT 0  'channel-1 unused
DEFINE CCP2_REG PORTC  'channel 2 port
DEFINE CCP2_BIT 3      'channel 2 bit (C3) used later
DEFINE CPP3_REG 0  'channel 3 unused
DEFINE CPP3_BIT 0  'channel 3 unused
DEFINE CCP4_REG 0  'channel 4 unused
DEFINE CCP4_BIT 0  'channel 4 unused
'*******************************************************************************
'
'  VARIABLES / ALIASES
MYLED var PORTA.5 'pin 2
MYLED1 VAR PORTA.1 'pin 18
'*******************************************************************************
'
'  MAIN PROGRAM
main:
pause 1000
MYLED=~MYLED
MYLED1=~MYLED1
goto main

end


Hserout questions

$
0
0
Hi All

Attempting to get some serial communication working with a 16f628 (4Meg Xtal) My defines are as below :-


DEFINE OSC 4
DEFINE HSER_TXSTA 24h
DEFINE HSER_RCSTA 90h
DEFINE HSER_BAUD 9600
DEFINE HSER_SPBRG 25

It works sometimes but not reliably ..... Any issues with above, ///maybe external xtal too slow ?

Just looking for a little guidance.

BR
Andy

Shiftout question about the manual statement

$
0
0
In the PBP3 manual there is this paragraph:

SHIFTOUT is a software-based command and does not require that the target device have synchronous serial capability. The ClockPin and DataPin parameters may be set to any digital I/O pins, and may be different in different commands within the same program.
\Bits optionally specifies the number of bits to be shifted out. If it is not specified, 8 bits are shifted out, independent of the variable type. The Bits shifted out are always the low order bits, regardless of the Mode used, LSB or MSB. Up to 32 Bits can be shifted out of a single (long) variable. If more than 32 Bits are required, multiple variables or constants may be included between the square brackets.


I am trying to understand the statement that is underlined, can anyone help?
does it mean that if you use the /Bits modifier at all that the bit order is not affected by Mode ?

Thanks!

Not or Invert

$
0
0
Very Very Quick question :-

I have a digital input..... How do I invert it in software , Brain freeze :-(

BR
Andy

Thank you all for reading

Elapsed timer data storage

$
0
0
Hello,
I try to create a simple milliseconds counter with DT Elapsed timer. The program works as follows: after initial countdown starts the timer, next if I press the "mic" button the "lap or split" time is shown on display and the count value is increment by one after each press.
Code:

'****************************************************************
'*  Name    : timer                                            *
'*  Author  : louis                                            *
'*  Notice  : Copyright (c)                                    *
'*          : All Rights Reserved                              *
'*  Date    : 24. 2. 2019                                      *
'*  Version : 1.0                                              *
'*  Notes  : PIC16F1829                                        *
'****************************************************************
 
#CONFIG
cfg= _FOSC_INTOSC
cfg&= _WDTE_OFF
cfg&= _PWRTE_OFF
cfg&= _MCLRE_OFF
cfg&= _CP_OFF
cfg&= _CPD_OFF
cfg&= _CLKOUTEN_OFF
cfg&= _IESO_OFF
cfg&= _FCMEN_OFF
#ENDCONFIG

wsave  VAR BYTE    $70    SYSTEM      ' alternate save location for W
 
include "DT_INTS-14.bas"            'Needs to be in same PBP folder as PBPW.EXE
include "ReEnterPBP.bas"            'Needs to be in same PBP folder as PBPW.EXE
include "ElapTimer_Interrupt.pbp"  'Needs to be in same PBP folder as PBPW.EXE

DEFINE OSC 8    ; Use a 8 MHZ internal clock
OSCCON = %01110000
CLKRCON = 0
APFCON0 = 0 
APFCON1 = 0
CM1CON0 = 0

CCP1CON = %00000000
CCP2CON = %00000000
ANSELA = %00000000
ANSELB = %00000000
ANSELC = %00000000
TRISA = %000000
TRISB = %11100000     
TRISC = %00000000
CM1CON0 = 0      ; Disable comparator 1
CM2CON0 = 0      ; Disable comparator 2
OPTION_REG.6=0
OPTION_REG.7=1

Define LCD_DREG PORTC
Define LCD_DBIT 0
Define LCD_RSREG PORTC
define LCD_RSBIT 4
define LCD_EREG PORTC
define LCD_EBIT 5
define LCD_BITS 4
define LCD_LINES 2
define LCD_COMMANDUS 2000
define LCD_DATAUS 50

ent var portb.5
res var portb.6
mic var portb.7
flag var bit
shot var byte
countd var byte
aray var byte

' Define and Create the Instant Interrupt for Timer1
ASM
INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
        INT_Handler  TMR1_INT,  _ClockCount,  PBP,  yes
    endm

    INT_CREATE            ; Creates the interrupt processor

    INT_ENABLE  TMR1_INT  ; Enable Timer 1 Interrupts 
ENDASM
zzac:
flag = 0
shot = 0
countd = 2

LCDout $FE, $80, " Timer  "
LCDout $FE, $C0, " ENTER  "
zac:
if ent = 0 then
LCDOut $FE,1
goto odpocet
endif
goto zac
odpocet:
countd = countd - 1
LCDout $FE, $80, "CNT:" , dec2 countd
pause 1000
if countd = 1 then goto start
goto odpocet


start:
Gosub ResetTime          ' Reset Time to  0d-00:00:00.000
Gosub StartTimer          ' Start the Elapsed Timer

main:
    if MSecsChanged = 1 then
        MSecsChanged = 0
        LCDout $FE, $80, dec2 Minutes, ":",dec2 Seconds, ".", dec2 MSecs       
    endif
    if mic = 1 then flag = 1
      if mic = 0 and flag = 1 then
          shot = shot + 1
          lcdout $FE, $C0 + 3, dec2 Seconds, ".", dec2 MSecs
        flag = 0
    endif
LCDout $FE, $C0, dec2 shot
if res = 0 then
    shot = 0
      lcdout $FE, $C0 + 3, dec2 Seconds, ".", dec2 MSecs
      gosub resettime
        countd = 2
    goto zzac
endif
if ent = 0 then
gosub stoptimer
goto showdata
endif
GOTO Main

showdata:
LCDout $FE, $80, "Saved DT"
lcdout $FE, $C0, dec2 shot," ", dec2 Seconds, ".", dec2 MSecs
if res = 0 then goto zzac
goto showdata

Thats works fine, but I want to store each "lap time" if i press the mic button and from this stored data calculate the split time between each press.
I try some variation with arrays, but no success.
Then I write this primitive attempt which stores five presses and calculate the splits.
Code:

'****************************************************************
'*  Name    : timer                                            *
'*  Author  : Louis                                            *
'*  Notice  : Copyright (c)                                    *
'*          : All Rights Reserved                              *
'*  Date    : 24. 2. 2019                                      *
'*  Version : 2.0                                              *
'*  Notes  : PIC16F1829                                        *
'****************************************************************
 
#CONFIG
cfg= _FOSC_INTOSC
cfg&= _WDTE_OFF
cfg&= _PWRTE_OFF
cfg&= _MCLRE_OFF
cfg&= _CP_OFF
cfg&= _CPD_OFF
cfg&= _CLKOUTEN_OFF
cfg&= _IESO_OFF
cfg&= _FCMEN_OFF
#ENDCONFIG

wsave  VAR BYTE    $70    SYSTEM      ' alternate save location for W
 
include "DT_INTS-14.bas"            'Needs to be in same PBP folder as PBPW.EXE
include "ReEnterPBP.bas"            'Needs to be in same PBP folder as PBPW.EXE
include "ElapTimer_Interrupt.pbp"  'Needs to be in same PBP folder as PBPW.EXE

DEFINE OSC 8    ; Use a 8 MHZ internal clock
OSCCON = %01110000
CLKRCON = 0
APFCON0 = 0 
APFCON1 = 0
CM1CON0 = 0

CCP1CON = %00000000
CCP2CON = %00000000
ANSELA = %00000000
ANSELB = %00000000
ANSELC = %00000000
TRISA = %000000
TRISB = %11100000     
TRISC = %00000000
CM1CON0 = 0      ; Disable comparator 1
CM2CON0 = 0      ; Disable comparator 2
OPTION_REG.6=0
OPTION_REG.7=1


Define LCD_DREG PORTC
Define LCD_DBIT 0
Define LCD_RSREG PORTC
define LCD_RSBIT 4
define LCD_EREG PORTC
define LCD_EBIT 5
define LCD_BITS 4
define LCD_LINES 2
define LCD_COMMANDUS 2000
define LCD_DATAUS 50

ent var portb.5
res var portb.6
mic var portb.7
flag var bit
shot var byte
countd var byte
shot1 var word
shot2 var word
shot3 var word
shot4 var word
shot5 var word
shot11 var word
shot22 var word
shot33 var word
shot44 var word
shot55 var word
sp1 var word 
sp2 var word
sp3 var word
sp4 var word
sp5 var word
ssp1 var word 
ssp2 var word
ssp3 var word
ssp4 var word
ssp5 var word
shot1 =0
shot2 =0
shot3 =0
shot4 =0
shot5 =0
shot11 =0
shot22 =0
shot33 =0
shot44 =0
shot55 =0   

' Define and Create the Instant Interrupt for Timer1
ASM
INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
        INT_Handler  TMR1_INT,  _ClockCount,  PBP,  yes
    endm

    INT_CREATE            ; Creates the interrupt processor

    INT_ENABLE  TMR1_INT  ; Enable Timer 1 Interrupts 
ENDASM

zzac:
flag = 0
shot = 0
countd = 2
shot1 =0
shot2 =0
shot3 =0
shot4 =0
shot5 =0
shot11 =0
shot22 =0
shot33 =0
shot44 =0
shot55 =0 
LCDout $FE, $80, " Timer  "
LCDout $FE, $C0, "ENT / GO"
zac:
if ent = 0 then
LCDOut $FE,1
goto odpocet
endif
goto zac
odpocet:
countd = countd - 1
LCDout $FE, $80, "GO:" , dec2 countd
pause 1000
if countd = 1 then goto start
goto odpocet


start:
Gosub ResetTime          ' Reset Time to  0d-00:00:00.000
Gosub StartTimer          ' Start the Elapsed Timer

main:
    if MSecsChanged = 1 then
        MSecsChanged = 0
        LCDout $FE, $80, dec2 Minutes, ":",dec2 Seconds, ".", dec2 MSecs
    endif
    if mic = 1 then flag = 1
    if mic = 0 and flag = 1 then
    shot = shot + 1
    lcdout $FE, $C0 + 3, dec2 Seconds, ".", dec2 MSecs
    if shot = 1 then shot11 = msecs 
    if shot = 1 then shot1 = seconds
    if shot = 2 then shot22 = msecs
    if shot = 2 then shot2 = seconds
    if shot = 3 then shot33 = msecs 
    if shot = 3 then shot3 = seconds
    if shot = 4 then shot44 = msecs 
    if shot = 4 then shot4 = seconds
    if shot = 5 then shot55 = msecs 
    if shot = 5 then shot5 = seconds
    flag = 0
    endif
LCDout $FE, $C0, dec2 shot
if res = 0 then
shot = 0
lcdout $FE, $C0 + 3, dec2 Seconds, ".", dec2 MSecs
gosub resettime
countd = 6
goto zzac
endif
if ent = 0 then
gosub stoptimer
goto showdata
endif
goto main

showdata:
pause 300
lo0:
lcdout $FE, $C0,"01 ", dec2 shot1, ".", dec2 shot11
sp1=(shot1*100) + (shot11-((shot11/100)*100))
ssp1=sp1
LCDout $FE, $80, "sp      "
lcdout $FE, $80,"sp ", dec2 ssp1/100,"." ,dec2 ssp1//100
lo1:
if ent = 0 then
pause 200
goto lo2
endif
if res = 0 then goto zzac
goto lo1

lo2:
lcdout $FE, $C0,"02 ", dec2 shot2, ".", dec2 shot22
sp2=(shot2*100) + (shot22-((shot22/100)*100))
ssp2=sp2-sp1
LCDout $FE, $80, "sp      "
lcdout $FE, $80,"sp ", dec2 ssp2/100,"." ,dec2 ssp2//100
llo2:
if ent = 0 then
pause 200
goto lo3
endif
if res = 0 then goto zzac
goto llo2

lo3:
lcdout $FE, $C0,"03 ", dec2 shot3, ".", dec2 shot33
sp3=(shot3*100) + (shot33-((shot33/100)*100))
ssp3=sp3-sp2
LCDout $FE, $80, "sp      "
lcdout $FE, $80,"sp ", dec2 ssp3/100,"." ,dec2 ssp3//100
llo3:
if ent = 0 then
pause 200
goto lo4
endif
if res = 0 then goto zzac
goto llo3

lo4:
lcdout $FE, $C0,"04 ", dec2 shot4, ".", dec2 shot44
sp4=(shot4*100) + (shot44-((shot44/100)*100))
ssp4=sp4-sp3
LCDout $FE, $80, "sp      "
lcdout $FE, $80,"sp ", dec2 ssp4/100,"." ,dec2 ssp4//100
llo4:
if ent = 0 then
pause 200
goto lo5
endif
if res = 0 then goto zzac
goto llo4

lo5:
lcdout $FE, $C0,"05 ", dec2 shot5, ".", dec2 shot55
sp5=(shot5*100) + (shot55-((shot55/100)*100))
ssp5=sp5-sp4
LCDout $FE, $80, "sp      "
lcdout $FE, $80,"sp ", dec2 ssp5/100,"." ,dec2 ssp5//100
llo5:
if ent = 0 then
pause 200
goto lo0
endif
if res = 0 then goto zzac
goto llo5   

GOTO showdata

Can someone explain me the better way to do this, how to store and read this data in arrays maybe.
Thanks,
Louis

16f677 adc Issue

$
0
0
I am moving from a 16F684 to a 16F677 for more I/O and having an issue with RA0. If RA0 pin is disconnected (floating} I measure 5.2V. My Vcc is 4.98V. If I ground RA0 with 10K I measure 0.19V. I swapped in a 16F1507 and that has no problem and works as expected. Unfortunately I need eeprom. I must be missing something in my i/o config. Any suggestions?

WPUA = 0 '%00000000
ANSEL = %00101101 '16F677 ANSEL
ANSELH = %00001110 '16F677 ANSELH
CM1CON0 = 0 ' Comparators OFF NO Comparators on PIC16F1507
CM2CON0 = 0

Thanks,
Ed

PBP3.1.2 (from PBP3.com)

$
0
0
  • Fixed bit-compare and bank-select for banks higher than 15 in K42/K83 families
  • Fixed compile error when using arrays with 10F3xx
  • Fixed HPWM for 16F18313/23, 16F1769
  • Changed default #CONFIG for 16(L)F15xxx family to set SOSC pins to normal I/O
  • Changed default #CONFIG for 16(L)F171x family to disable ZCD on power up
  • Fixed HPWM CCPTMRSx-selection for 18(L)FxxK42
  • Fixed PPS and HPWM for 16F161x family
  • Fixed missing SFRs in 18LFxxK42 devices
[Originally posted by Charles Leo, reposted by mpgMike]

Alternative Energy International Expo

$
0
0
There will be an Alternative Energy International Expo in Clearwater, Florida this March 23 and 24th. The venue is a 5000 square foot building with ample parking, vendors & speakers throughout the 2 days. There are nearby hotels, restaurants, and of course, ocean. Speakers include:
  • Walt Jenkins; considered to be the modern Stanley Meyer, running his dune buggy on >95% water. Like Stan, he has taken a unique approach to converting the inherent energy in water to kinetic energy at the wheels. Also like Stan, Walt uses no conventional electrolyzer. Instead, he combines other technologies to “energize” the water and extract its power. Teaming up ultrasonics, electro-magnetics, and high voltage ionizers, the system powers internal combustion engines with virtually no regulated exhaust emissions — just water and a touch of carbon dioxide (from the <5% gasoline).
  • Ed Grimm; Quality Inspector for NASA, took his space-race education and applied it to the HHO process. Development involved high level chemistry, metallurgy, and other laws of physics. Then, thinking outside the box, he explored practical uses for this unique gas. Whereas a typical HHO system requires about 70 amps to achieve a 20% fuel economy gain on a big rig, Ed’s system taps only 15 amps from the alternator.
  • Mike Holler; recognized by the US Federal Court System as a Fuel Economy Expert, will be delivering upwards of 3 seminars. Topics include teaching a layman’s approach to working through the electronic controller development process. Segmenting seemingly complex processes into smaller functions reduces the overwhelming to the mere doable. It won’t be an electronics or programming tutorial, but more about how to coalesce ideas into something an engineer can run with. Another subject is getting better fuel economy on your late model daily driver. Today cars are electronically controlled and tightly regulated, with performance gains getting harder to conquer. Finally, Mike will showcase an abbreviated history of fuel economy, including a 10 minute documentary.
  • Moray B. King*; considered one of the leading experts in Free Energy on the planet today. Moray has not yet been confirmed, but is over 90% probable. Author of several books on Free Energy, practically anything he shares is most worthwhile
  • Dave Parker; Head of the Free Energy Party, will be delivering useful information on how "Free Energy" is founded in real science.


*Tentative


There are still affordable vendor spaces available, as well as another speaker spot. To get tickets, or to simply learn more, go to: http://www.alternativeenergyinternational.com. Due to Florida’s licensing and tax laws, we chose not to include meals as part of the package.

RISC instructions explained

$
0
0
A good video about RISC computer instructions

String formatting

$
0
0
two closely related questions:
I have a serial interface 16x2 character LCD display, using DEBUG to talk to it, is working fine

I want to format a label and a number like this (2 lines shown)
-----------------
Pot
20
-----------------
Pot
2144
-----------------

notice the right hand justification of the number
I know I could use some IF's and move the cursor prior to outputting the number but I would also need to clear the leading blank area which slows things down and is a pain

My question is whether one of the String modifiers can do anything for me here ?
something like "right justify" so it is padded with leading spaces, or leading 0's could be OK too

and does DEBUG even support the BIN HEX etc string modifiers ?
I think the manual says it does but I kept getting compile errors

I should say though that I am quite rusty on this stuff but I can't make the syntax work, probably doing something wrong

any examples would be appreciated even if they don't directly help this question posed,
am referring to Debug command usage examples of section 2.11 in the manual
thanks!

Finding the MCU I need on MICROCHIP's website

$
0
0
Hi there,

I'm asking for some guidance on how to use the MAPS or the Parametric Search Tool from MICROCHIP.

My project consists of driving a 8x8 LED matrix. So, to make it a little more "easy" for me to program, I'd like to find an MCU that has at least two in-a-raw (from 0 to 7) 8bits Outgoing PORTs (i.e. PORTA.0...PORTA.7 and PORTB.0...PORTB.7).

As I'm short in space, I can not just pick-up a 40 pins MCU and voilà.

I do have some MCUs in my drawer but, unfortunately, most of them have at least one of the PORT working only as an Input (mostly PORTA.5).

Currently, I have to read every and single datasheet to find out what I'm looking for.

But is there a better and faster way to do so?

16F1829 PORTA.5 problem

$
0
0
Hello Folks,
I'm struggling a few days how to set port RA5 on PIC 16F1829 as general purpose I/O (output).
I try everything but no succes, I think the problem is around oscillator configuration, because the pin still in CLKIN state (or something else), not as gen. purpose I/O.
Please, can someone help me with proper configuration.
Here is the test code, and config:
Code:

; MCU PIC16F1829                                       
 
#CONFIG
cfg= _FOSC_INTOSC
cfg&= _WDTE_OFF
cfg&= _PWRTE_OFF
cfg&= _MCLRE_OFF
cfg&= _CP_OFF
cfg&= _CPD_OFF
cfg&= _CLKOUTEN_OFF
cfg&= _IESO_OFF
cfg&= _FCMEN_OFF
#ENDCONFIG

DEFINE OSC 8    ; Use a 8 MHZ internal clock
OSCCON = %01110000
CLKRCON = 0
APFCON0 = 0 
APFCON1 = 0
CM1CON0 = 0

CCP1CON = %00000000
CCP2CON = %00000000
ANSELA = %00000000
ANSELB = %00000000
ANSELC = %00000000
TRISA = %000000
TRISB = %00000000     
TRISC = %00000000
CM1CON0 = 0      ; Disable comparator 1
CM2CON0 = 0      ; Disable comparator 2
OPTION_REG.6=0
OPTION_REG.7=1

led var porta.5

main:
high led
pause 500
low led
pause 500
goto main

isd4003 arll that matterr

$
0
0
I need to record voice in an ISD4003. Using the audio input with a condenser mic isn't sensitive enough. I added a 1 transistor preamp which works well but it now has a ticking noise. Filtercaps eveyrwhere don"t help. Any suggestions? Thank you.
Viewing all 4787 articles
Browse latest View live