PDA

View Full Version : New member



jmgelba
- 12th February 2004, 05:16
Hi Folks,

Just introducing myself (and my problems!)

I am a complete beginner at programming and thought I would start with PBP as it was recommended to me. I am using 2.43.

I am a pcb layout guy by day, and avid rally fan by any other time.
It's my hobby that brought me the need to program. I am trying to create a set of gauges for my car. Boost, oil pressure, oil temp, EGT, etc etc.
I am just starting out on my first project which is the boost gauge.
I've read what i can so far about setting up program structure and finding out how to get an ADC value from the pin into a word. I thought i had got the idea, but when i tried to complie what i had done so far i got a bunch of errors that i dont understand.

Here is a copy of the code:


11 INCLUDE 16F628.BAS
12 DEFINE OSC 20
13 DEFINE ADC_BITS 10
14 DEFINE ADC_CLOCK 3
15 DEFINE ADC_SAMPLEUS 10
16 TRISA = %00000001 'set portA pin 1 only
17 ADCON1 = %10000010 'read as analog
18 RAW VAR WORD 'Set ADC value to name of RAW
19 ADCIN 0, RAW 'READ ADC store value to RAW

Here are the errors:

line 11 bad variable modifier:.bas
line 11 syntax error


I removed the include and got this:

error[113] D:\progra~1\pbp\pbppic14.lib 5741 : symbol not previously defined (ADCON0)

I got this error for \pbppic14.lib 5775, 5780 and 5781.
I aslo got more "symbols not previously defined" for ADCON1, GO_DONE, ADRESH, ADRESL all with different numbers attached.

Could someone shed some light on my ramblings??

Jusat to check i ran this:
'************************************************* ****************************
'* MICROCODE STUDIO TIPS *
'* *
'* (1) : To get context sensitive help, move your cursor to a PICBasic *
'* : command and then press F1. *
'* (2) : Program assumes the PIC is running at 4MHz. To change the default *
'* : setting (for example, to 20MHz) simply add DEFINE OSC 20 at the *
'* : top of your program. *
'* *
'* This sample program is supplied courtesy of microEngineering Labs Inc *
'************************************************* ****************************

' PicBasic Pro program to display result of
' 10-bit A/D conversion on LCD
' Connect analog input to channel-0 (RA0)

' Define LCD registers and bits
Define LCD_DREG PORTD
Define LCD_DBIT 4
Define LCD_RSREG PORTE
Define LCD_RSBIT 0
Define LCD_EREG PORTE
Define LCD_EBIT 1

' Define ADCIN parameters
Define ADC_BITS 10 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
adval var word ' Create adval to store result

TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %10000010 ' Set PORTA analog and right justify result
Low PORTE.2 ' LCD R/W line low (W)
Pause 500 ' Wait .5 second

loop:
ADCIN 0, adval ' Read channel 0 to adval
Lcdout $fe, 1 ' Clear LCD
Lcdout "Value: ", DEC adval ' Display the decimal value

Pause 100 ' Wait .1 second

Goto loop ' Do it forever
End





I got the same errors as before, plus a bunch more for the LCD

What am I doing wrong????



Best regards,

James

Ingvar
- 12th February 2004, 09:07
Hi James,

It looks like you're trying to use a 16F628, unfortunatley this PIC does not have an AD converter. It only have onboard comparators.

/Ingvar

jmgelba
- 12th February 2004, 16:21
Ahhhh. Ok.
I will buy the full version of Micro Code Plus and find a different device.


James.

jmgelba
- 17th February 2004, 05:20
Woohoo, software will be here tomorrow!

OK, Im trying to measure the voltage coming from a pressure sensor with an output of 0.2v to 4.9v.
On my desk it reads 1.79 to 1.80v. The device is supposed to read 0.2v at 2.9 psi (no 0 psi reading is specified) and 4.9v at 36.9psi (max). This would lead me to beleive its reading atmosphere as 14.7psi and thus outputting ~1.8v. I can lower the output by placing a vacuum on it.
My question is, I need to have a display reading 0 psi at atmosphere, so how do I offset 1.8v's worth of 10bit ADC counts in my program, and how do I make my display read a vacuum value at anything below 1.8v? This needs to be a different scale (HG v PSI.)
Obviously, I need to have correct calibration from a display reading of 0 psi to (36.9 - 14.7) 22.2psi so do I do...

(4.9v-0.2v)/1024=0.0045v per count.
0.2v/0.0045v=44.4 counts for min output of device.
1.8v/0.0045v=400 counts for atmosphere, "display" reading of "0psi", or 14.7psi.
1024-400=624 counts from "display" reading of 0psi to 22.2psi


So, 1 display psi = 624/22.2psi=28.1 counts if anything below 400 counts is ignored.
This means atmosphere by these calculations should be 14.7 x 28.1 = 413.07 counts, or..
36.9-2.9=34psi/1024=0.033psi per count. x 400 = 13.2psi x 413.07 = 13.63psi
Obviously, something is wrong here.

Please help me prove Im not insane. Why do I always try maths after a beer and past my bedtime??

Regards,

James

Ingvar
- 17th February 2004, 11:23
Hi again,

Took a quick look at your calculations and saw that you got (4.9v-0.2v)/1024=0.0045v, i calculate that to 0.00458984375...... So you have a big rounding error, that's not a good start....... You need to use more precice than that.

Which sensor are you using?

/Ingvar

jmgelba
- 17th February 2004, 17:21
I think I made a fundimental error right at the start. I calculated mV per count incorrectly.
Instead of 4.9-0.2/1024, I should have done this...

4.9/1024=0.00478515625v per count. Reason being, the ADC does not start at 0.2v, it starts at ground.

The sensor Im using is a Motorola MPX4250A. After re-reading the data sheet, there is a chart on there that shows an output of 1.8v at 14.7psi - which is what Im getting.

So I should be able to work out what 14.7psi is in counts...

1.8v/0.00478515625v =376.163265. or 376 in the real world.

Therefore counts per psi = 376/14.7= 25.578231 rounded to 26.

So, now I know that anything below a count of 376 needs to have a display of zero, how do I create the offset? Or, better still anything below a count of 376 needs to be in a different scale for measuring vacuum. And, have do I make 26 counts equal 1 psi?

Thanks for sticking with me through this.

James

Ingvar
- 18th February 2004, 19:45
Ok, second attempt, i managed to erase my message before sending it ....... duuuuuhhhhhhh.

Looking at the datasheet i find the following.
1. Sensitivity is 20mV/kPa(137.893mV/psi)
2. There is an offset of approximatley 10kPa(1.45psi)

First i'd convert the AD reading into millivolts. This is easy to do by using the */ operator, this command makes a multiplication and an "invisible" division by 256 .....

milliVolts = ADreading */ 1250

.... same as doing ......

milliVolts = ADreading * 1250/256

..... on your calculator.

Now it's time to convert to psi, it probably won't be good enough just to divide our millivolts with 137.894 since that would give a reading in whole psi. We want better, i suggest psi*100, 14.7 psi would be 1470. I do this by using the ** operator, this is the same as */ but it divides by 65536 instead. So...

psiTimes100 = milliVolts / 137.893 * 100

.... equals.....

psiTimes100 = milliVolts * (100/137.893)

.... equals ....

psiTimes100 = milliVolts * 0.7252

.... which is the same as .....

psiTimes100 = milliVolts ** 47527

This would be the result if we didn't have an offset, but we do, so let's take that into account. Easy enough, just add them ....

psiTimes100 = psiTimes100 + 145

So our complete calculation should(could) look like this ....

milliVolts = ADreading */ 1250 'convert to millivolts
psiTimes100 = milliVolts ** 47527 'convert to psi*100
psiTimes100 = psiTimes100 + 145 'add the offset

Using 1.80V we end up with 1447 which is pretty darn close to your estimated 14.7 psi. If you live above sealevel and/or it's cloudy that's quite reasonable. You could get even better accuracy by measuring the output at two known pressures. From this you could calculate both the sensitivity and offset.

To dispaly vacuum i a different unit you simply separate them at your desired 14.7 psi.

IF psiTimes100 >= 1470 THEN
displayvalue = psiTimes100 - 1470 'dispaly zero at sealevel
'LCDOUT or SEROUT or whatever you want to use
ELSE
'do necessary calculations to produce your desired result
'and display it
ENDIF

Clear as mud?????
/Ingvar

jmgelba
- 20th February 2004, 14:58
Thanks so much for your time and effort helping me out. Much apreciated.
Clear as mud??? Not too bad actually.
My software arrived and I've moved to a PIC16F818 to retain the 10bit ADC and the ability to run at 20MHz. The PIC's are in the post so hopefully this weekend i can complie a test program and see if i can get a psi reading into the serial port on my PC.
From there on, I have to figure out how to write code for a 3 digit 7 seg multiplexed display.

I was wondering if i could run the code you provided first, stored the value, and used it as an offset calibration for altitude. Then apply it to the same code again, run in the main part of the program to give a true altitude adjust reading. Obviously you want 0 psi displayed at 10,000 feet just like you would at sea level. I dont know by how much atmospheric pressure changes at different altitudes. Nothing a search wont turn up.

Once again, thanks for the wonderful help and advice.


James.

Ingvar
- 20th February 2004, 18:17
I don't want to spoil your day but i must inform you that you probably will need to spend some more $$$$$ on a new sensor. If you always want a zero reading with zero pressure applied, regardless of the atmosperic pressure, you should have bought a gauge(or differential with one side open to surrounding) sensor. That type of sensor measures pressure relative to the surrounding(atmosperic) pressure. Now you have an absolute sensor that measures pressure relative to an internal vacuum, a common use for this type of sensor is to measure atmosperic pressure.

Or perhaps i haven't understood what you're trying to accomplish, what exactly is it your trying to build?

/Ingvar

jmgelba
- 20th February 2004, 22:34
The sensor i have is vented to atmosphere and reads 2.9 - 36.9psi. Therefore it reads 14.7 psi (1.8v) at sea level.
What i was trying to say was, on power up, take a sample of the reading of surrounding atmospheric pressure and send the value to the eeprom. Use this value to set a display reading of 0psi. Offset all readings from this point forward with the eeprom value to provide an accurate representation of pressure applied relative to current atmospheric pressure.

Instruct the owner to undergo a calibration routine when the unit is first installed or if a sample can be taken quick enough, every time the unit is turned on before the engine is started.

The application is a turbo boost gauge. The sensor was selected because it was designed for this purpose and i have seen a working gauge using this sensor.
If i get adventurous enough, there will be a vacuum reading too.

Does this clear things up a little??

Regards,

James.

jmgelba
- 22nd February 2004, 18:45
Ok you guys, here's where Im at.......



DEFINE OSC 20
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 10
TRISA = %11000001 'set portA
ADCON1 = %10000010 'read as analog
RAW VAR WORD 'Set ADC value to name of RAW
ADCIN 0, RAW 'READ ADC store value to RAW
millivolts VAR WORD
psitimes100 var word
millivolts = RAW */ 1250 'convert ADC to millivolts
psitimes100 = millivolts ** 47527 'convert millivolts to psi*100
psitimes100 = psitimes100 + 145 ' add sensor offset
TRISB = %11111111 'set portB all outputs

Main:

display3: psitimes100 = psitimes100 / 100 ' Find number of hundreds
psitimes100 = psitimes100 // 100 ' Remove hundreds from psitimes100
Gosub bin2seg ' Convert number to segments
Poke PortB, psitimes100 ' Send segments to LED
PortA.3 = 0
Pause 1 ' Leave it on 1 ms
PortA.3 = 1' Turn off digit to prevent ghosting
psitimes100 = psitimes100 / 10 ' Find number of tens
psitimes100 = psitimes100 // 10 ' Remove tens from psitimes100
Gosub bin2seg ' Convert number to segments
Poke PortB, psitimes100 ' Send segments to LED
PortA.4 = 0 ' Turn on second digit
Pause 1 ' Leave it on 1 ms
PortA.4 = 1
psitimes100 = psitimes100 ' Get number of ones
Gosub bin2seg ' Convert number to segments
Poke PortB, psitimes100 ' Send segments to LED
PortA.5 = 0' Turn on first digit
Pause 1 ' Leave it on 1 ms
PortA.5 = 1
Return ' Go back to caller

bin2seg: Lookup psitimes100, [0 = PortB %00111111, 1 = PortB %00000110, 2 = PortB %01011011, 3 = PortB %01001111, 4 = PortB %01100110, 5 = PortB %01101101, 6 = PortB %01111101, 7 = PortB %00000111, 8 = PortB %01111111, 9 = PortB %01101111], psitimes100
Return
Goto Main


Everything complies except for the lookup table which gives me an error...


error line 50, expected "]"

So apart from this, have I passed PicBasic programming 101 yet??? :-)

Thanks,

James.

Ingvar
- 23rd February 2004, 11:00
Hi James,

What you're trying to do is quite possible to accomplish. I'd still use a different(gauge or differential) sensor if i only wanted to monitor and display the pressure. If i wanted to control the engine i'd choose teh absolute type(the one you have now). The reason for this is that when controling the engine it's interesting to know the absolute pressure since the air contains different ammounts of oxygen at different pressures. If all i wanted to do was to monitor(and display) the pressure relative to the atmosperic pressure, i'd use a gauge(or differential) sensor since that sensor gives an output relative to the sourrounding(atmosperic) pressure. This way i'd get rid of the need to calibrate and also the errors created when the atmosperic pressure is changing. Imagine this scenario - Start your engine at sealevel, it will now be calibrated. Drive up a mountain 2 miles high, your sensor will still show pressures relative to sealevel but the atmosperic will now be a lot less. If this error doesn't bother yoy then you can go ahead with the design as you have planned, if not, it's time to buy another sensor.

Over to the program, there are a few things that needs to be changed.
1. You have a subroutine named "display3" ending with a return, but you never call it. Instead you've put it in the mainloop. Big nono, the return will cause the stack to underflow.
2. The lookup statement should not contain any "0=PortB" or similar.
3. TrisB should be zero for all outputs.
4. Poke is allowed but it doesn't look good. I'd use "PortB=".....
5. It could be a good idea to use more descriptive names on your variables, "psitimes100" is used almost everywhere for almost everything. It will work but will be awful to read when the program grows.

The program could look like this with the errors removed......

DEFINE OSC 20
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 10
TRISA = %11000001 'set portA
ADCON1 = %10000010 'read as analog
RAW VAR WORD 'Set ADC value to name of RAW
ADCIN 0, RAW 'READ ADC store value to RAW
millivolts VAR WORD
psitimes100 var word
millivolts = RAW */ 1250 'convert ADC to millivolts
psitimes100 = millivolts ** 47527 'convert millivolts to psi*100
psitimes100 = psitimes100 + 145 ' add sensor offset
TRISB = %00000000 'set portB all outputs


Main:
GOSUB display3
Goto Main

display3: psitimes100 = psitimes100 / 100 ' Find number of hundreds
psitimes100 = psitimes100 // 100 ' Remove hundreds from psitimes100
Gosub bin2seg ' Convert number to segments
PortB = psitimes100 ' Send segments to LED
PortA.3 = 0
Pause 1 ' Leave it on 1 ms
PortA.3 = 1' Turn off digit to prevent ghosting
psitimes100 = psitimes100 / 10 ' Find number of tens
psitimes100 = psitimes100 // 10 ' Remove tens from psitimes100
Gosub bin2seg ' Convert number to segments
PortB = psitimes100 ' Send segments to LED
PortA.4 = 0 ' Turn on second digit
Pause 1 ' Leave it on 1 ms
PortA.4 = 1
psitimes100 = psitimes100 ' Get number of ones
Gosub bin2seg ' Convert number to segments
PortB = psitimes100 ' Send segments to LED
PortA.5 = 0' Turn on first digit
Pause 1 ' Leave it on 1 ms
PortA.5 = 1
Return ' Go back to caller

bin2seg: Lookup psitimes100, [%00111111, %00000110, %01011011, %01001111, %01100110, %01101101, %01111101, %00000111, %01111111, %01101111], psitimes100
Return

I haven't looked at the AD settings, i'm not familiar with your chip(F818).

The mud is getting less murky......
/Ingvar

jmgelba
- 28th February 2004, 23:26
Well, thanks for all the help Ingvar, but, its not working!!

Ok, i complied the code you provided and got nothing at all. Scratched my head for a few hours, then realized that id been supplied common cathode instead of common anode digits. No problem, made the 0's 1's and vice versa, and nothing.

Added pull down resistors to get a good ground and things started to shape up.

However, i was seeing the same info on two digits. I had an output connected to MCLR, which is a no no. Relocated and data on all three digits at last.
Unfortunatly, the data is garbage, no numbers at all.

Checked, recheck and checked again all the connections, everything was connected correctly to the oputputs. Still getting garbage.

Wrote a small program to cycle through the segments one at a time to see if id used the wrong pinout data.
All correct, RB0 equalled the first segment, all the way to RB6 equalls last segment - wired correctly, programmed correctly.

Getting frustrated now.

Problems i have now:

1. Wrong info ouptut to displays
2. only getting 1 sample from the ADC
3. not updating display - allways shows first ADC value

1. No idea what the problem is. I have slowed everything down to display the data on each of the 3 digits for 1 second each. Data is not different if i spend 1 second or 1ms at each display. So i dont think there is a timing issue.

2. So far ive managed to get a grand total or 2 readings max out of the adc by reading the adc, writing it to eeprom, pausing 10, then reading it back, giving it a different name and using that name to send to the display.

UPDATE
I tweaked the settings of portA and the ADC and managed to get samples out now but the values are very close together when im swinging the input from near 0v to 4.5v. There is still no update on the display.

3. How do i know im getting samples?? Well i take an adc reading every 100ms and write it to eeprom. I do this for 16 samples at 16 different locations, then plug the pic into my programmer and read the eeprom data. I can see the data writen over time and see that it varies slightly.
Still, the first sample is taken and i presume displayed since i cant tell exactly what its supposed to on the displays. After that, the display does not change.

Ive tried a number of different programs, one should cycle 0 - 9 on a single digit - compiled, did not work. This was copied from the picbasic website. Cycles garbage. Modified it, displays are better but still not numbers.


The only way i have gotten correct numbers out is by writing the program below, but even this stop cylcling and displays 0 after a while. Yes, i know there isnt anythingh done with the ADC but i left it in anyway.

include "modedefs.bas"
DEFINE OSC 20
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50
TRISA = %11000001 'set portA
ADCON0 = %11000101 'read as analog
ADCON1 = %00001110
RAW VAR WORD 'Set ADC value to name of RAW
millivolts VAR WORD
psitimes100 var word
Pause 100
TRISB = %00000000 'set portB all outputs
'turn on all digits, set display to be blank at startup
PortA.2 = 0
PortA.3 = 0
PortA.4 = 0
PortB.0 = 1 'A
PortB.1 = 1 'B
PortB.2 = 1 'C
PortB.3 = 1 'D
PortB.4 = 1 'E
PortB.5 = 1 'F
PortB.6 = 1 'G
PortB.7 = 1 'DP

Main
gosub ZERO
pause 1000
Gosub ONE
pause 1000
gosub TWO
pause 1000
gosub THREE
pause 1000
GOSUB FOUR
pause 1000
Gosub FIVE
pause 1000
gosub SIX
pause 1000
gosub SEVEN
pause 1000
gosub EIGHT
pause 1000
gosub NINE
pause 1000

ZERO
PortB.0 = 0 'A
PortB.1 = 0 'B
PortB.2 = 0 'C
PortB.3 = 0 'D
PortB.4 = 0 'E
PortB.5 = 0 'F
PortB.6 = 1 'G
PortB.7 = 1 'DP
Return

ONE
PortB.0 = 1 'A
PortB.1 = 0 'B
PortB.2 = 0 'C
PortB.3 = 1 'D
PortB.4 = 1 'E
PortB.5 = 1 'F
PortB.6 = 1 'G
PortB.7 = 1 'DP
Return

TWO
PortB.0 = 0 'A
PortB.1 = 0 'B
PortB.2 = 1 'C
PortB.3 = 0 'D
PortB.4 = 0 'E
PortB.5 = 1 'F
PortB.6 = 0 'G
PortB.7 = 1 'DP
Return

THREE
PortB.0 = 0 'A
PortB.1 = 0 'B
PortB.2 = 0 'C
PortB.3 = 0 'D
PortB.4 = 1 'E
PortB.5 = 1 'F
PortB.6 = 0 'G
PortB.7 = 1 'DP
Return

FOUR
PortB.0 = 1 'A
PortB.1 = 0 'B
PortB.2 = 0 'C
PortB.3 = 1 'D
PortB.4 = 1 'E
PortB.5 = 0 'F
PortB.6 = 0 'G
PortB.7 = 1 'DP
Return

FIVE
PortB.0 = 0 'A
PortB.1 = 1 'B
PortB.2 = 0 'C
PortB.3 = 0 'D
PortB.4 = 1 'E
PortB.5 = 0 'F
PortB.6 = 0 'G
PortB.7 = 1 'DP
Return

SIX
PortB.0 = 0 'A
PortB.1 = 1 'B
PortB.2 = 0 'C
PortB.3 = 0 'D
PortB.4 = 0 'E
PortB.5 = 0 'F
PortB.6 = 0 'G
PortB.7 = 1 'DP
Return

SEVEN
PortB.0 = 0 'A
PortB.1 = 0 'B
PortB.2 = 0 'C
PortB.3 = 1 'D
PortB.4 = 1 'E
PortB.5 = 1 'F
PortB.6 = 1 'G
PortB.7 = 1 'DP
Return

EIGHT
PortB.0 = 0 'A
PortB.1 = 0 'B
PortB.2 = 0 'C
PortB.3 = 0 'D
PortB.4 = 0 'E
PortB.5 = 0 'F
PortB.6 = 0 'G
PortB.7 = 1 'DP
Return

NINE
PortB.0 = 0 'A
PortB.1 = 0 'B
PortB.2 = 0 'C
PortB.3 = 1 'D
PortB.4 = 1 'E
PortB.5 = 0 'F
PortB.6 = 0 'G
PortB.7 = 1 'DP
Return

goto Main



I will post my code in another reply.


Regards,

James.

jmgelba
- 28th February 2004, 23:44
Further down is the program that will record the ADC value into eeprom. It works perfectly and i can read all the stored values from the EPIC programmer. It also cycles through the individual segments to prove my wiring is correct, which it is.

I see that this could be the basis for a new program.
Take an ADC reading, place it in eeprom, read it, and display it.
Questions regarding this would be, how do i get the value stored in eeprom into decimal, and how do i display the 100's, 10's and 1's on their correct digit?
How would i create a lookup table where i can specifically say that a number "one" should be:

PortB.0 = 0 'A
PortB.1 = 0 'B
PortB.2 = 0 'C
PortB.3 = 0 'D
PortB.4 = 0 'E
PortB.5 = 0 'F
PortB.6 = 1 'G
PortB.7 = 1 'DP

Then i just call for "ONE" when a 1 needs to be displayed.
If i could do this for all the numbers, then figure out which number should be displayed on which digit, life would be good!

I have tried a lookup table like this where i am calling PortB = bin2seg

bin2seg: Lookup psitimes100, [%1000000, %1111001, %1000100, %1110000, %0011001, %0010010, %0000010, %1111000, %0000000, %1000000], psitimes100

It does not seem to work!

Anyway, here is the extend of several days of frustration!!....



include "modedefs.bas"
DEFINE OSC 20
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50
TRISA = %11000001 'set portA
ADCON0 = %11000101 'read as analog
ADCON1 = %00001110
RAW VAR WORD 'Set ADC value to name of RAW
millivolts VAR WORD
psitimes100 var word
Pause 100
TRISB = %00000000 'set portB all outputs
PortA.2 = 0
PortA.3 = 0
PortA.4 = 0
PortB.0 = 1 'A
PortB.1 = 1 'B
PortB.2 = 1 'C
PortB.3 = 1 'D
PortB.4 = 1 'E
PortB.5 = 1 'F
PortB.6 = 1 'G
PortB.7 = 1 'DP

Main

ADCIN 0, RAW 'READ ADC store value to RAW
millivolts = RAW */ 1250 'convert ADC to millivolts
psitimes100 = millivolts ** 47527 'convert millivolts to psi*100
psitimes100 = psitimes100 + 145 ' add sensor offset


PortB.0 = 0 'A
PAUSE 1000
PortB.0 = 1 'A

PortB.1 = 0 'B
PAUSE 1000
PortB.1 = 1 'B

PortB.2 = 0 'C
PAUSE 1000
PortB.2 = 1 'C

PortB.3 = 0 'D
PAUSE 1000
PortB.3 = 1 'D

PortB.4 = 0 'E
PAUSE 1000
PortB.4 = 1 'E

PortB.5 = 0 'F
PAUSE 1000
PortB.5 = 1 'F

PortB.6 = 0 'G
PAUSE 1000
PortB.6 = 1 'G

WRITE 0, psitimes100
pause 100
WRITE 1, psitimes100
pause 100
WRITE 2, psitimes100
pause 100
WRITE 3, psitimes100
pause 100
WRITE 4, psitimes100
pause 100
WRITE 5, psitimes100
pause 100
WRITE 6, psitimes100
pause 100
WRITE 7, psitimes100
pause 100
WRITE 8, psitimes100
pause 100
WRITE 9, psitimes100
pause 100
WRITE 10, psitimes100
pause 100
WRITE 11, psitimes100
pause 100
WRITE 12, psitimes100
pause 100
WRITE 13, psitimes100
pause 100
WRITE 14, psitimes100
pause 100
WRITE 15, psitimes100: write 16, millivolts: write 17, raw
pause 5000

GOTO Main


Regards,

James.