Ok, im fairly sure it's 10k, the red could well be orange, it was ordered from rapid electronics and says 10k on the bag, and is deffo 9.98 on the multimeter, looking at the resistors there is very little difference between red and orange, or im colour blind :P
Sorry for the confusion
Thing is, if the one end of the resistor is positive, then surely the end (middle of the two) that connects to RA.0 is always going to be negative as it currently is.
The PROGRAM directive sets the execution start point (at a label.) When the NOSTARTUP option is used the SXB compiler will NOT insert the normal start-up code that pre-initializes all RAM addrs to zero; in this case the programmer is responsible for appropriate initialization...
Note that when the NOSTARTUP option is used the TRIS registers are NOT initialized, so you MUST set up the ports as INPUTs or OUTPUTs.
djh82uk's program has the NOSTARTUP option.
So, even though somebody uses:
InPin PIN RA.0 INPUT CMOS
OutPin PIN RA.1 OUTPUT
Does it matter where it is placed?· If so, How?· Should it be after the PROGRAM directive?
Is a TRIS_A = %0001 (A pin0 = in, pin1 = out) required still (TRIS_A = %00000001 for SX48)?
I've always put everything after the PROGRAM directive.· I've never used NOSTARTUP.
It isn't clear to me that RA.0 is made an INPUT and/or RA.1 is made an OUTPUT if they get declared as such before the PROGRAM directive (or if that matters, but I think it must.)
Will this Compile and Run --
DEVICE SX48, OSC4MHZ
FREQ 4_000_000
PROGRAM Start
Start:
'TRIS_A = %00000001
a VAR Byte
InPin PIN RA.0 INPUT CMOS
OutPin PIN RA.1 OUTPUT
Led1 PIN RA.2 OUTPUT 'Result Indicator
Led2 PIN RA.3 OUTPUT 'Acquisition annunciator
Testing:
Led1 = 0
Led2 = 0
ANALOGIN InPin, OutPin, a, 1
IF a > 150 THEN LED1 = 1 'Threshold appx 2.9V
Led2 = 1 'indicates acquisition
PAUSE 2000
GOTO Testing
I will give it a go tommorrow as it's 3am atm, I think RA.1 is deffo working as an output as it appears so in debug, and gives out 5V when it says it is, but I see what you mean by the input.
ok, code would not work without an endif statement,
however it seems that it ignores the input/output directives if under the "start:" as the led does not work, put them above the start and the led shows red, but still not getting any voltage.
OK.
Well, I copied over the 1.51.03 stuff (but now I don't have Help anymore, except the PDF, the .chm doesn't work.)
I re-wrote, a bit, the previous, and this Compiles:
DEVICE sx28, oschs3, TURBO, STACKX, OPTIONX
IRC_CAL IRC_SLOW
FREQ 10_000_000
PROGRAM Start
a VAR Byte
start:
TRIS_A = %00000001
'RA.0 analogin's input
'RA.1 analogin's output
'RA.2 Result Indicator
'RA.3 Acquisition annunciator
Inpin PIN RA.0 INPUT CMOS
Testing:
RA.2 = 0
RA.3 = 0
ANALOGIN Inpin, RA.1, a, 2
IF a > 150 THEN Good 'Threshold appx 2.9V
RA.3 = 1 'indicates acquisition
PAUSE 2000
GOTO Testing
Good:
RA.2 = 1
RETURN
No ENDIF needed.··
I guess the THEN·can't be to a "RA.x = _" like I had, so I made a "Good" subroutine to turn the "> 150" LED on with.·
I don't have any SX48s, only SX28s.
So, it'll be a bit till I can get the circuit together and all, but that's what I'll be doing.
Thanks PJ, driving me nuts, I still don't understand how it's going to work by the diagram, I just don't see how ra.0 can ever sense a possitive voltage.
Above code does not work either, same problem in that RA.0 is just not getting to se any voltage, i still think it may be a circuit problem, but as I said, i cannot see how it can ever be anything other than ground
Thanks for all your help btw, I do really appreciate it
DEVICE sx28, oschs3, TURBO, STACKX, OPTIONX
IRC_CAL IRC_SLOW
FREQ 10_000_000
PROGRAM Start
a VAR Byte
blink VAR Byte
start:
TRIS_A = %00000001
'RA.0 analogin's input
'RA.1 analogin's output
'RA.2 Result Indicator YEL
'RA.3 Acquisition annunciator GRN
LVL_A = %00000001
Testing:
a = 0
RA.2 = 0
RA.3 = 0
ANALOGIN RA.0, RA.1, a, 1
IF a > 150 THEN Good 'Threshold appx 2.9V ?
Back:
RA.3 = 1 'indicates acquisition
PAUSE 2000
FOR Blink = 0 TO 9 'Blink ACQ before re-testing
RA.3 = 0
PAUSE 100
RA.3 = 1
PAUSE 100
NEXT Blink
GOTO Testing
Good:
RA.2 = 1
GOTO Back
Looks like I cannot IF...THEN...GOSUB (?), so I made the "Back" subroutine.
The threshold looks to be approx. 1.2V.· I think that's because·with·my·10MHz clock I should probably have used a smaller value CAP.· The "manual" states that the optimal value will be found with experimentation (so, experiment.)
I made a video, but youtube is a slag cow today.· If I·can get it U/L'd· later (>15 min. and it never finalized) I'll P-M you and post here same.
I've broken practically every "style" rule, but it's documented well, in my opinion, and it's so short that·one should be able to follow along anyway.
If you leave the input floating then the result LED will be unreliable. POST EDIT -- Success, at last. ·http://www.youtube.com/watch?v=dpq536hl4DE
** I've used the LEDs·as a troubleshooting aid because I only have an SX-Blitz.· I thought about sending the ANALOGIN value 'a' to a serial LCD, but I thought that would unnecessarily complicate matters. **
I had to change the pins for the led as im using a tri-colour led, so just swapped ra.3 for ra.4 and set ra.3 to always be 0
took out the reference to the chip type and crystal, then used the device dialog box to set the chip to sx48 and crystal to internal 4MHz, problem is nothing happens, no leds or anything, and no voltage to the led pins, if I run it in debug nothing happens there either, it just sits at _progstart.
I really appreciate all you have done PJ, I feel like im letting things down from my end, it's been ages since ive touched an SX which just isn;t helping, ive been over the circuit a hundred times, im wondering if there is something I should be doing different due to the fact it's an SX48?
OK, may be getting somweher, PIN RA.4 just will not work, won't put out any voltage is it a Special/dual function pin on the sx48? trying to find the datasheet now
Im so stupid, there isn't an RA.4, it's labelled on the board, has tracks going to it etc, but I presume it was for the SX52 or something, datasheet just confirmed, I would have thought it was RE that had only 4 pins and not RA, oh well, time to re-solder.
All thanks to PJ Allen of course, basically the problem was that it just would not work with RA.0, changed it to RC.0 and it worked with the code that PJ had written for it. I did try a different pin earlier on in this quest, but I think it still did not work due to the code not being right, but once PJ had a go at it it all got sorted [noparse]:)[/noparse]
The readings are a little funny, but consistent, I am using it in a cold shed, cheapo capacitors and the internal crystal at 4MHz, but it's doing it's jon and im happy.
Thanks a lot PJ and anyone else that added input [noparse]:)[/noparse]
Reminds me why i should stick to parallax micro's, for the forum support as I definatley need it
HMM, ive got it testing 2 voltages and it works, but if I drop the coltage on the RB test it's fine, re-apply power and it goes back to testing, but if I drop the voltage on the RC test then it does not update the value and stays in the lower voltage mode, although the relay does click on and off.
Comments
You can look at either the CHM or the PDF of the help file for the ANALOGIN documentation from this thread:
http://forums.parallax.com/showthread.php?p=597707
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
Sorry for the confusion
Thing is, if the one end of the resistor is positive, then surely the end (middle of the two) that connects to RA.0 is always going to be negative as it currently is.
DJH
DJH
There we read:
The PROGRAM directive sets the execution start point (at a label.)
When the NOSTARTUP option is used the SXB compiler will NOT insert the normal start-up code that pre-initializes all RAM addrs to zero; in this case the programmer is responsible for appropriate initialization...
Note that when the NOSTARTUP option is used the TRIS registers are NOT initialized, so you MUST set up the ports as INPUTs or OUTPUTs.
djh82uk's program has the NOSTARTUP option.
So, even though somebody uses:
InPin PIN RA.0 INPUT CMOS
OutPin PIN RA.1 OUTPUT
I've always put everything after the PROGRAM directive.· I've never used NOSTARTUP.
Post Edit -- For me, it's always...
DEVICE sx28, oschs3, TURBO, OPTIONX
IRC_CAL· IRC_SLOW
FREQ···· 28_000_000
PROGRAM· starter
starter:
· this is where all of my programming starts
Post Edited (PJ Allen) : 1/24/2008 12:45:29 AM GMT
DJH
Will this Compile and Run --
I will give your code a try
Thanks [noparse]:)[/noparse]
DJH
however it seems that it ignores the input/output directives if under the "start:" as the led does not work, put them above the start and the led shows red, but still not getting any voltage.
DJH
Well, I copied over the 1.51.03 stuff (but now I don't have Help anymore, except the PDF, the .chm doesn't work.)
I re-wrote, a bit, the previous, and this Compiles:
No ENDIF needed.··
I guess the THEN·can't be to a "RA.x = _" like I had, so I made a "Good" subroutine to turn the "> 150" LED on with.·
I don't have any SX48s, only SX28s.
So, it'll be a bit till I can get the circuit together and all, but that's what I'll be doing.
Thanks for all your help btw, I do really appreciate it
DJH
OK -- It works:
Looks like I cannot IF...THEN...GOSUB (?), so I made the "Back" subroutine.
The threshold looks to be approx. 1.2V.· I think that's because·with·my·10MHz clock I should probably have used a smaller value CAP.· The "manual" states that the optimal value will be found with experimentation (so, experiment.)
I made a video, but youtube is a slag cow today.· If I·can get it U/L'd· later (>15 min. and it never finalized) I'll P-M you and post here same.
I've broken practically every "style" rule, but it's documented well, in my opinion, and it's so short that·one should be able to follow along anyway.
If you leave the input floating then the result LED will be unreliable.
POST EDIT -- Success, at last.
·http://www.youtube.com/watch?v=dpq536hl4DE
** I've used the LEDs·as a troubleshooting aid because I only have an SX-Blitz.· I thought about sending the ANALOGIN value 'a' to a serial LCD, but I thought that would unnecessarily complicate matters. **
Post Edited (PJ Allen) : 1/26/2008 8:16:54 PM GMT
I had to change the pins for the led as im using a tri-colour led, so just swapped ra.3 for ra.4 and set ra.3 to always be 0
took out the reference to the chip type and crystal, then used the device dialog box to set the chip to sx48 and crystal to internal 4MHz, problem is nothing happens, no leds or anything, and no voltage to the led pins, if I run it in debug nothing happens there either, it just sits at _progstart.
I really appreciate all you have done PJ, I feel like im letting things down from my end, it's been ages since ive touched an SX which just isn;t helping, ive been over the circuit a hundred times, im wondering if there is something I should be doing different due to the fact it's an SX48?
DJH
Im so stupid, there isn't an RA.4, it's labelled on the board, has tracks going to it etc, but I presume it was for the SX52 or something, datasheet just confirmed, I would have thought it was RE that had only 4 pins and not RA, oh well, time to re-solder.
let you know how it goes
DJH
DJH
All thanks to PJ Allen of course, basically the problem was that it just would not work with RA.0, changed it to RC.0 and it worked with the code that PJ had written for it. I did try a different pin earlier on in this quest, but I think it still did not work due to the code not being right, but once PJ had a go at it it all got sorted [noparse]:)[/noparse]
The readings are a little funny, but consistent, I am using it in a cold shed, cheapo capacitors and the internal crystal at 4MHz, but it's doing it's jon and im happy.
Thanks a lot PJ and anyone else that added input [noparse]:)[/noparse]
Reminds me why i should stick to parallax micro's, for the forum support as I definatley need it
DJH
can the SX48 check voltage with analogin on different pins one after the other? Or can it only be used on one pin per program?
DJH
Any ideas?
DEVICE SX48, OSC4MHZ
FREQ 4_000_000
PROGRAM Start 'NOSTARTUP
a VAR Byte
b VAR Byte
blink VAR Byte
start:
TRIS_A = %00000000
TRIS_B = %00000001
TRIS_C = %00000001
'RC.0 analogin's input
'RC.1 analogin's output
'RA.2 Result Indicator YEL
'RA.3 Acquisition annunciator GRN
LVL_C = %00000001
LVL_C = %00000001
Testing:
'a = 0
RA.1 = 0
RA.2 = 0
RA.3 = 0
RB.3 = 0
RB.4 = 0
ANALOGIN RC.0, RC.1, a, 2
'pause 1000
ANALOGIN RB.5, RB.6, b, 2
watch a
watch b
IF a < 190 THEN Charge1
IF b < 190 THEN Charge2 'Threshold appx 2.9V ?
Back:
RA.1 = 0
RA.3 = 1
RB.3 = 1 'indicates acquisition
PAUSE 2000
FOR Blink = 0 TO 9 'Blink ACQ before re-testing
RA.3 = 0
RB.3 = 0
PAUSE 100
RA.3 = 1
RB.3 = 1
PAUSE 100
NEXT Blink
GOTO Testing
Charge1:
RA.2 = 1
RA.1 = 1
RB.3 = 1
pause 5000
IF b < 190 THEN Charge2
GOTO Testing
Charge2:
RA.3 = 1
RB.4 = 1
Pause 5000
GOTO Testing
the code is very similar between charge 1 and charge2, but even if I make them identical it still does not work
Any ideas?
DJH