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

DT_ints handling time.

$
0
0
Hello to everyone.

My question is: Does anyone know the minimum time it takes for the interrupt handler (DT_Ints) to kick in and start processing the interrupt? I currently have one interrupt on change actively waiting for a port pin to change. I want to know if anyone knows how long it takes for the interrupt handler to react/respond to the port pin change. The particular device I'm using is the 18F67K40. Its data sheet states the a minimum of 50nS after changing states, is needed at a logic 1 or 0 in order for the IOC to be valid. Does anyone know how long after that, it takes for DT_ints to start processing the interrupt.

My current setup:
Using high priority interrups.
PortG.5 is set to generate an interrupt on a positive going edge.
I set PortG.3 to logic 1 to indicate that I have entered the interrupt.

I use this setup to time the interrupt from when it's being generated and when I respond to it.
The current time is 9.5 microSeconds. It may not be a long time but i need it to be faster than that.

All feedback is appreciated.

Indented lines

$
0
0
I rarely use PBP and have some code that looks like the page formatting was screwed up -- some lines are indented rather than a nice tight left margin.

Refresh my memory please -- indented lines do or do not matter to PBP pro ? -- thanks

If they do, where do they matter?

Programmer help

$
0
0
I need to ask another question. I have an old EPIC parallel port programmer but no parallel port convenient right now so need to use either serial or usb.

I have a Pickit programmer but hate it and don't want to install Mchip software if I don't have to. The EPIC is great because all you do is load a hex file and burn the chip -- that's it. 2 steps. For my occasional use, that works for me -- too much to remember with the pickit.

Is there a programmer that is either serial port or USB that runs on Win7 that will be as easy as my old EPIC? -- thanks very much for any help.

Receive Data From Ethernet Module

$
0
0
BACKGROUND:

I'm using a 18F6520 PIC and a USRIOT Ethernet module (USR-TCP232-T2). This is a nice little module that seems to work very well and is inexpensive ~$12. I've been using this for a couple months successfully sending data from the PIC to the module (in TCP Client mode).

The only pins I'm connecting are the +5v, +3v, gnd, TX and RX.

Now I want to receive data sent from a computer to the module and to the PIC. I'm now running the module in TCP Server mode(only way I could ping the port and get the module to receive data). I am listening on HSERIN2, I have a usb connection on HSERIN/OUT1.

CURRENT CONDITION:

I am monitoring the Ethernet Module via it's IP address and embedded web page so I can see what's getting to it and I have the PIC outputting anything it gets on HSEROUT1 to the PBP serial monitor.

When I send the first packet to the module, it goes all the way through to the PIC and life is good. All subsequent packets make it to the Ethernet module but never get passed to the PIC.

I am guessing that I need to send the Ethernet module some sort of confirmation, reset, okay to receive again, thank you note, salute, acknowledgement signal? But I can’t find anything on this. I’m wondering if this is a normal/standard thing with PIC to Ethernet Module communications or if someone has cracked this nut before?

REFERENCE:
Module: https://www.usriot.com/products/seri...et-module.html
Manual for module: https://www.usriot.com/support/downl...er-manual.html

Thanks for joining me down this rabbit hole!

Pickit3 pin verify

$
0
0
I've never used this Pickit3 so want to make sure I get this right. I have the zif socket on it and it looks like for an 18dip 16F628A that pin 1 on the chip is placed into pin 11 on the zif socket? It's a bit concerning using it first time. Hard to see it. -- thanks

ADXL345 accelerometer

$
0
0
Hello all,

I'm trying to connect ADXL345 accelerometer to MCU in SPI 4wire mode, but no success. The reading is allways zero.
In I2c mode the accelerometer works just fine.
I think in SPI mode I forgot something, because I'm not familiar with SPI communication.
Here is my code, it reads two axis, and display raw value on lcd.
Can someone check the code and point me what I'm doing wrong.
Thanks for any suggestion.

Code:

'******************************************************************
'*  Name    : ADXL345 accelerometer test  SPI mode                *
'*  Author  : Louis                                              *
'*  Notice  :                                                    *
'*          : All Rights Reserved                                *
'*  Date    : 3. 5. 2019                                          *
'*  Version : 1.0                                                *
'*  Notes  : 16F688                                              *
'*          :                                                    *
'******************************************************************

#CONFIG
cfg = _INTRC_OSC_NOCLKOUT
cfg&= _WDT_OFF
cfg&= _PWRTE_OFF
cfg&= _MCLRE_OFF
cfg&= _CP_OFF
cfg&= _CPD_OFF
cfg&= _BOD_ON
cfg&= _IESO_ON
cfg&= _FCMEN_ON
  __CONFIG cfg
#ENDCONFIG

DEFINE OSC 8
OSCCON = %01110000

CMCON0 = 7
ANSEL = %00000000
TRISA = %000000   
TRISC = %00000000

DEFINE LCD_DREG PORTC ;Define PIC port used for LCD Data
DEFINE LCD_DBIT 0 ;Define first pin of portb
DEFINE LCD_RSREG PORTC ;Define PIC port used for RS line of
DEFINE LCD_RSBIT 4 ;Define Portb pin used for RS
DEFINE LCD_EREG PORTC ;Define PIC prot used for E line of LCD
DEFINE LCD_EBIT 5 ;Define PortB pin used for E
DEFINE LCD_BITS 4 ;Define the 4 bit communication
DEFINE LCD_LINES 2 ;Define using a 2 line LCD
DEFINE LCD_COMMANDUS 2000 ;Define delay between sending LCD
DEFINE LCD_DATAUS 50 ;Define delay time between data sent.
pause 30

CS      var PortA.2    'chip select
CLK    var PortA.1    'clock
SDI    var PortA.4    'mosi
SDO    var PortA.5    'miso

AX1        VAR        WORD  'X dir accel
AY1        VAR        WORD  'Y dir accel


ACDATA1        var        byte    'shiftin bytes
ACDATA2        var        byte    'shiftin bytes
ACDATA3        var        byte    'shiftin bytes
ACDATA4        var        byte    'shiftin bytes

lcdout $FE,1

low CS
pause 1
shiftout SDI,CLK,1,[$2D\8,%00001000\8] 'setting to measure mode
high CS

pause 1

low CS
pause 1
shiftout SDI,CLK,1,[$31\8,%00000000\8] 'setting to +-2g range, SPI 4wire mode
high CS

pause 1

start_measure:
low cs
pause 1
shiftout SDI,CLK,1,[$32\8] ;get FIFO to read first adress
shiftin SDO,CLK,1,[ACDATA1,ACDATA2,ACDATA3,ACDATA4] 'shiftin acceleration values
high CS

AX1.highbyte=ACDATA1
AX1.lowbyte=ACDATA2
AY1.highbyte=ACDATA3
AY1.lowbyte=ACDATA4

lcdout $FE,$80, "X: ", dec5 AX1
lcdout $FE,$C0, "Y: ", dec5 AY1

goto start_measure

Write not working with 12f1571

$
0
0
This wont compile using 12F1571 but will work with 12F629. anybody else have this problem?
Remove the write command error goes away.

M Var byte
m=5
write 0,m

DC Motor constant speed controller, is Picbasic fast enough?

$
0
0
Hello, I want to build a DC motor controller, which will allow speed adjustment and also support for constant speed under changing load. I want to use HPWM to generate PWM signal, and adjust it's duty cycle based on data which I will read from hall sensor, via PULSIN statement. I plan to use PIC16F886 and motor speeds will vary in 5-15K Rpm range. Will picbasic be fast enough to handle it, or I need to use ASM ?

DT_INTS-18 for 27K40

$
0
0
Hi guys
I am planning to use PIC18F27K40, it is absolutely necessary to use DT_INTS-18
for the project. I will also use low priority interrupts. I have seen several
modifications of DT_INTS-18 to cope with these chips but I am uncertain of
which one to use. The versions I have run in to are DT_INTS-18-K40, DT_INTS-18_3_4b
and DT_INTS-18_3_4c. How well are they tested? As I understood there were some
issues with low priority interrupts. In one thread I read about DT_INTS-18_3_4c
but the link to the software was not working. If this is the one, does anyone
have this code?

Best regards

Lasse

Getting data from user, how to store it properly? (kinda dialog interface)

$
0
0
Hello.

I'm building a simple digital controller, which works like this: User enters number of points (steps) to move head to. At each step, user enters desired x/y/z positions and movement speeds. Then the task is done based on user entered data. However, user might choose 1 or say 32 points (steps) to do. How get this data from user, and where to store it? my rough idea is like this



Code:

FOR A=0 TO B*5 STEP 5' where B is number of total steps to be done.
GOSUB ENTRYFORM 'Go to subroutine, where user enters X/Y/Z/Speed data. this routine returns values in variables X, Y, Z, S, where each hold appropriate data like position and speed
WRITE A, X 'Write data to eeprom
WRITE A+1,Y
WRITE A+2,Z
WRITE A+3,S
NEXT

I guess this will work, but is there a way to do it without using eeprom ? and there might be another data too, so not all chips might have enough eeprom available. I think it is possible to do this using ARRAYWRITE, but I did not fully understood how to use it, despite reading the reference manual. For the array variables, it is ok, but since I'm using PIC16F886 device, and array variables there are limited to 48 WORD variable, this might allow me to store only 12 "steps" - almost same limitation as eeprom. So it there a way to have more "steps", say 30-40, each of which holds set of 4 WORD variables?

Low power accurate 6 month timer - suggestions?

$
0
0
Hi folks,

I'm looking for suggestions on achieving the lowest power, but accurate, timer to last around 6 months.

It will be at the bottom of the ocean and I have minimal real estate to fit the timer inside an acoustic device so a RTC is out of the question. This device will initially operate for an hour as confirmation on deployment and then sleep (off, powered by the PIC/mosfet) for a period of 180 days. After this the device will be powered up and remain so until its battery supply is exhausted (approx. 2 weeks).

I've looked at DT's Elapsed Timer but sleep command results in havoc with the interrupts it seems, so I'm thinking an SMD 12LF1840 running from a coin cell counting wake-ups from 10 second sleep events could be an avenue. Some quick and dirty code sees about 10uA average consumption using a 4Mhz crystal but speed isn't an issue, but power, size and accuracy is.

Does anyone have any suggestions other than above to offer?

Thanks and regards to all,
Bill

AD8302 Phase and magnitude to complex impedance

SSD1315 oled display

$
0
0
Hello folks,

recently I bought a bunch of 128x64 and 128x32 I2c oled displays with SSD1306 driver, but after few try's I realized it came with different driver.
The actual driver is SSD1315. I try get it worked with Richard's includes but no success. The displays not get initialised. In available "datasheets" I can't see any major differences.
Then I tryed the displays with arduino and its includes (named as for SSD1306 and the displas works).
If anyone has any suggestion how to deal with this SSD1315 driver displays in PBP, it will be great.

Thanks,
Louis

Demystifying Thermopile IR Temp Sensors

$
0
0
Thermopile temperature sensor or temp sensors offer the advantage of non-contact temperature measurement, making them more and more popular over the standard contact-based temp sensors. Thermopile sensors use infrared (IR) radiation versus conduction for heat transfer, which provides unique solutions that allow for new levels of performance and reliability in many constrained applications.


Engineers working on the thermal management of electronic equipment have long enjoyed the simplicity and convenience of the digital temp sensing ICs. The new integrated car accessories ICs on the market provide the temperature results in the same convenient digital format. The continuous reduction in their power, size, and cost creates opportunities with consumer devices, medical instruments, office equipment and home appliances.


The most active adoption of small thermopile IR sensors is in portable devices such as notebooks, tablets, and smartphones. Measuring the case temperature controller provides key input in optimizing performance. Keeping the processor running at peak power, while maintaining the case temperature comfortable for the user, is the main design constraint in the pursuit of more processing power in smaller form factors.


Using contact temp sensors on the board to correlate its temperature to the case temperature yields very inaccurate results. Plus, it doesn't account for any changes of the ambient conditions, i.e., using your tablet outside in a sunny day or in a hockey rink. A contact temp sensor glued to the case, with wires connecting it to the board, can solve that problem. But it's a nightmare for manufacturing as it involves manual assembly and has poor reliability.


A thermopile IR temp sensor can be mounted to a printed circuit board (PCB) with standard automated processes. It measures both the board and case temperature, which allows for true feedback control and optimization.


Another attractive application for IR intelligent toilet temperature sensor is temperature monitoring and control of moving objects such as heater rolls in laser printers. In these cases, using contact-based temp sensors comes with many draw-backs. For example, the point of contact wears out from friction during movement. This gets exacerbated by applying normal force on the sensor to achieve good thermal contact. Also, the contact location might not be at the point of interest. This creates a time-constant for heat transfer between the two locations and could compromise the control system's efficiency. An IR temp sensor can eliminate all these constraints.

Lcdout macro problem

$
0
0
So, there I was happily programming away... slowly putting together the attached menu tree and suddenly, between one compile and the next, this error shows up: Macro LCDOUTSTR?W not found in macro file. Some things I verified or can infer.
  • I've never seen this before
  • I'm using PBP3.1
  • 8 bit 18F4420
  • This is the only active section of the program other than configuring
  • I've been making incremental changes for days. Literally working one minute - error the next.

I'm just hoping somebody can put me on the track to solve this. I've searched for the error on the forum and on the internet and do not find anything related.


Code:

'READ KEYPAD
KEY_READ:
  PAUSE 50
  FOR L1 = 0 TO 3
    LATC = %00000000
    LATC.0[L1] = 1
    FOR L2 = 4 TO 7
      IF PORTC.0[L2] = 1 THEN
        SELECT CASE PORTC
          CASE %00010001 : KEY_PTR = 0 : RETURN    'RESET
          CASE %00100001 : KEY_CODE[KEY_PTR] =  0                               
          CASE %01000001 : KEY_CODE[KEY_PTR] = "#"           
          CASE %10000001 : KEY_CODE[KEY_PTR] = "D"
           
          CASE %00010010 : KEY_CODE[KEY_PTR] =  7
          CASE %00100010 : KEY_CODE[KEY_PTR] =  8
          CASE %01000010 : KEY_CODE[KEY_PTR] =  9
          CASE %10000010 : KEY_CODE[KEY_PTR] = "C"
             
          CASE %00010100 : KEY_CODE[KEY_PTR] =  4
          CASE %00100100 : KEY_CODE[KEY_PTR] =  5
          CASE %01000100 : KEY_CODE[KEY_PTR] =  6
          CASE %10000100 : KEY_CODE[KEY_PTR] = "B"

          CASE %00011000 : KEY_CODE[KEY_PTR] =  1
          CASE %00101000 : KEY_CODE[KEY_PTR] =  2
          CASE %01001000 : KEY_CODE[KEY_PTR] =  3
          CASE %10001000 : KEY_CODE[KEY_PTR] = "A"
        END SELECT

        'CLEAR ROW 3 & 4
        LCDOUT $FE, $94, REP " "\20 : LCDOUT $FE, $94
        LCDOUT $FE, $D4, REP " "\20 : LCDOUT $FE, $D4
       
        FOR D1 = 0 TO KEY_PTR
          IF KEY_CODE[D1] < 10 THEN
            LCDOUT DEC KEY_CODE[D1] 
          ELSE
            LCDOUT KEY_CODE[D1]
          ENDIF
        NEXT D1
       
        IF KEY_PTR = 3 THEN
          DEV_NUM = KEY_CODE[1] * 10 + KEY_CODE[2]
          select case DEV_NUM
            case 1                : LCDOUT $FE, $94, "CLOCK  " : LCDOUT $FE, $D4, "          "
            CASE 2, 3, 4, 5, 6, 7 : LCDOUT $FE, $94, "PLUG #", DEC2 DEV_NUM - 1
            CASE 8, 9, 10        : LCDOUT $FE, $94, "DOSE #", DEC2 DEV_NUM - 8
          END SELECT
        ENDIF
             
        IF KEY_PTR = 6 THEN
          DEV_REG =  KEY_CODE[4] * 10 + KEY_CODE[5]
          SELECT CASE DEV_NUM 'NAME EACH DEVICE REGISTER
          CASE 1 'CLOCK
            select case DEV_REG
              CASE 1 : LCDOUT $FE, $94, "R:1 MINUTES "
              CASE 2 : LCDOUT $FE, $94, "R:2 HOURS  "
              CASE 3 : LCDOUT $FE, $94, "R:3 DOW    "
              CASE 4 : LCDOUT $FE, $94, "R:4 DATE    "
              CASE 5 : LCDOUT $FE, $94, "R:5 MONTH  "
              CASE 6 : LCDOUT $FE, $94, "R:6 YEAR    "           
              CASE ELSE : LCDOUT $FE, $94 : LCDOUT "ERR: * RESET"
            END SELECT
          CASE 2, 3, 4, 5, 6, 7 'PLUGS
            select case DEV_REG
              CASE 1  : LCDOUT $FE, $94, "R:1 ON TIME "
              CASE 2  : LCDOUT $FE, $94, "R:2 OFF TIME"
              CASE 3  : LCDOUT $FE, $94, "R:3 DAY PTRN"
              CASE 4  : LCDOUT $FE, $94, "R:4 2ND ON  "
              CASE 5  : LCDOUT $FE, $94, "R:5 2ND OFF "           
            CASE ELSE : LCDOUT $FE, $94, "ERR: * RESET"
          END SELECT
          CASE 8, 9, 10 'DOSE PUMPS
            select case DEV_REG
              CASE 1 : LCDOUT $FE, $94, "R:1 ON TIME "
              CASE 2 : LCDOUT $FE, $94, "R:2 RUN TIME"
              CASE 3 : LCDOUT $FE, $94, "R:3 DAY PTRN"
              CASE 4 : LCDOUT $FE, $94, "R:4 PWM%  "         
              CASE ELSE : LCDOUT $FE, $94, "ERR: * RESET"
            END SELECT
          END SELECT             
        ENDIF
       
        IF KEY_PTR = 12 THEN
          'REG_VAL = KEY_CODE[8] * 1000 + KEY_CODE[9] * 100 + KEY_CODE[10] * 10 + KEY_CODE[11]
        ENDIF
             
        KEY_PTR = KEY_PTR + 1
        PAUSE 1000           
      ENDIF
    NEXT L2
  NEXT L1
 
 
 
  IF KEY_PTR < 11 THEN GOTO KEY_READ
    'LCDOUT $FE, $D4, "D#", DEC2 DEV_NUM, " R#", DEC2 DEV_REG, " V#", DEC4 REG_VAL
  PAUSE 5000
  'WRITE REGISTER VALUE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
RETURN


Question Regarding A>D Conversion

$
0
0
When configuring an A>D conversion, we all know that configuring it to process too quickly can provide erroneous results, but if you go the other way and say configure max A/D Acquisition time select bits (say 20 TAD) and max A/D conversion clock select bits (say Fosc/64). can doing that compromise the aquisition quality in any way (assuming we're in no hurry)?

It's just reading the datasheet for the PIC18F27J53 it says (p367):
"For correct A/D conversions, the A/D conversion clock (TAD) must be as short as possible but greater than the minimum TAD (see parameter 130 in Table 31-30 for more information)."

Param 130:
No.------Symbol------Characteristic-------Min.-----Max.------Units----------Conditions
130-------TAD-------A/D Clock Period-----0.8-----12.5(1)-----us-------TOSC based, VREF  3.0V

Note 1: The time of the A/D clock period is dependent on the device frequency and the TAD clock divider.

So, I'm assuming the acquisition time can be safely long, but the conversion time?

Thanks

Troy

Au-full quiet out here lately...

$
0
0
Wow, Is it just me, or is it Summer and everybody is outside doing chores. Now that I'm retired and check the site's I see a minimum of activity. I hope everybody is having a great Summer so far..... I have got my 3D printer working overtime making table lamps for my daughters outdoor wedding...

Pickit3 -- hate the friggin thing

$
0
0
Life was so easy with my old parallel port programmer.
Using Pickit3 -- did everything right I think. MPLAB and the IPE are installed. 16F628A is installed correctly (not in a circuit but the zif socket)

IPE loads fine -- communicates seemingly but get error message

"Target device was not found (could not detect target voltage VDD). You must connect to a target device to use PICkit 3."

Please -- would appreciate any leads on what's wrong. Driving me NUTS. --thanks

APA102C and SK9822

$
0
0
I have some code working fine on an led strip that is defined as APA102/SK9822. I'm not sure however that those are drop inreplacements for each other as I connected the same circuit to some discrete SK9822 (supposedly) and it isn't functioning.

Would anyone know ? Are they completely interchangeable on a functional basis? (not specs). thanks

with the pic16f628a off, a voltage on an1 comes out from main voltage pin, why?

$
0
0
with the pic off (no power) the voltage applied on an1 (a battery) comes out from the vcc pin, i don't understand why...
Viewing all 4787 articles
Browse latest View live