Thank you for all the input!!
Have been contacted By Parallax and the test results are in.
The PLC manufactured by Lawicel HB of Sweden may itself be the source of the noise!....
I am in the process of communicating with them and will keep you updated on the results.
Hopes are that it can be resolved because the PLC other than that, seems to work GREAT!! www.lawicel-shop.se/shop/
Thanks again: Gene
Added 3/03 : PS. "THE PLC IS NOT THE PROBLEM !!"
See next post
It works....................................
Chris and Pat you were correct on it being a code issue !
I went as far as I could go with my limited code experience and the demo code supplied.
I contacted an engineer at the manufacturer and he was sure footed as they come. On a Sunday "SUNDAY NO LESS" he popped into the office and saw the problem we have been working on, ran some test and was confident it was NOT THE PLC He then forwarded some code to test and it works Great !
The demo code that is in the manual supplied with the PLC is unstable.
Chris Thanks,I will forward the new code to you.
There is only 1 quirk and that is the ADC inputs marked 1234 are actually 4321.
The oscilloscope, multimeter and PLC output are within +- .2mV throughout the scale "outstanding!" Tested it with the sensor, "perfect!"
MUCH better than I need for the current project.
Sorry for the delay on posting the code,I wanted permission from lawicel Before I did.
They replied before I thought to ask and said feel free to post it, Wow! talk about forward thinking.
It just leaves you with that warm fuzzy feeling.
Thank you again Lars for the code.....
'{$STAMP BS2P} 'STAMP directive (specifies a BS2P)
'{$PBASIC 2.5}
'{$PORT COM1}
'
'
' (C) LAWICEL AB, www.lawicel.se, Lars Wictorsson
'
' Editor Version 2.4
'
' Testing the PLC-EZ1 module with BS2P24
'
'
Led1 CON 8
Led2 CON 9
Led3 CON 10
Led4 CON 11
Led5 CON 12
Led6 CON 13
Led7 CON 14
Led8 CON 15
inload CON 1 ' Input 1
digin1 CON 6
digin2 CON 7
anacs CON 3
INPUT 6
INPUT 7
result VAR Byte
adresult VAR Word
bOut VAR Byte
bOut = 1
'
' Set the Chip Select High on ADC and the Load signal of HC165
'
HIGH inload
HIGH anacs
overagain:
'
' This part clocks in 8 digital inputs and display result binary
'
LOW inload
PAUSE 1
HIGH inload
PAUSE 1
SHIFTIN 2,0, LSBPRE, [noparse][[/noparse]result]
DEBUG HOME, ISBIN8 result
'
' This part reads in one of the 2 inputs that goes directly
'
IF (IN6=1) THEN DEBUG "0" : ELSE DEBUG "1"
IF (IN7=1) THEN DEBUG "0" : ELSE DEBUG "1"
'
' This part reads one ADC channel and prints out result in mV
'
LOW anacs
PAUSE 1
SHIFTOUT 4,0, MSBFIRST, [noparse][[/noparse]192]
PAUSE 1
HIGH anacs
PAUSE 1
LOW anacs
PAUSE 1
SHIFTIN 5,0, MSBPRE, [noparse][[/noparse]adresult\12]
PAUSE 1
HIGH anacs
adresult = adresult * 10 / 78 * 10
DEBUG " ADC1=",SDEC adresult, "mV ",CR
'
' Toggle one Output
'
IF bOut = 1 THEN
LOW Led2
PAUSE 100
HIGH Led2
ELSEIF bOut = 2 THEN
LOW Led1
PAUSE 100
HIGH Led1
ELSEIF bOut = 3 THEN
LOW Led4
PAUSE 100
HIGH Led4
ELSEIF bOut = 4 THEN
LOW Led3
PAUSE 100
HIGH Led3
ELSEIF bOut = 5 THEN
LOW Led6
PAUSE 100
HIGH Led6
ELSEIF bOut = 6 THEN
LOW Led5
PAUSE 100
HIGH Led5
ELSEIF bOut = 7 THEN
LOW Led8
PAUSE 100
HIGH Led8
ELSEIF bOut = 8 THEN
LOW Led7
PAUSE 100
HIGH Led7
ENDIF
PAUSE 50
bOut = bOut + 1
IF bOut = 9 THEN bOut = 1
GOTO overagain
SHIFTOUT·4,0,·MSBFIRST,·[noparse][[/noparse]192]
192 is 11000000
According to the PLC manual (wow, thats changed already! You guys are fast) thats 1 for start bit, 1 for the MSB of the channel bits (apparently the ADC channels connected are not 0-3 but 4-7), 00 to select the analog channel (00 = channel 4). So you're connecting the sensor to channel 4?
I also see internal timer is being used again but the pause·apparently gives it enough time to complete a conversion.
Pat:
That's correct
The debug reads DEBUG " ADC1=",SDEC adresult, "mV ",CR But the input # on the PLC is 4
There is the same magic on the input and output #'s However there is a piece of code in the manual that corrects that, but it uses valuable space.
Comments
Thank you for all the input!!
Have been contacted By Parallax and the test results are in.
The PLC manufactured by Lawicel HB of Sweden may itself be the source of the noise!....
I am in the process of communicating with them and will keep you updated on the results.
Hopes are that it can be resolved because the PLC other than that, seems to work GREAT!!
www.lawicel-shop.se/shop/
Thanks again: Gene
Added 3/03 : PS. "THE PLC IS NOT THE PROBLEM !!"
See next post
Post Edited (Cheese) : 3/4/2008 3:44:54 AM GMT
It works....................................
Chris and Pat you were correct on it being a code issue !
I went as far as I could go with my limited code experience and the demo code supplied.
I contacted an engineer at the manufacturer and he was sure footed as they come. On a Sunday "SUNDAY NO LESS" he popped into the office and saw the problem we have been working on, ran some test and was confident it was NOT THE PLC He then forwarded some code to test and it works Great !
The demo code that is in the manual supplied with the PLC is unstable.
Chris Thanks,I will forward the new code to you.
There is only 1 quirk and that is the ADC inputs marked 1234 are actually 4321.
The oscilloscope, multimeter and PLC output are within +- .2mV throughout the scale "outstanding!" Tested it with the sensor, "perfect!"
MUCH better than I need for the current project.
THE PLC from Parallax and Lawicel is rock steady.
Sorry for the delay on posting the code,I wanted permission from lawicel Before I did.
They replied before I thought to ask and said feel free to post it, Wow! talk about forward thinking.
It just leaves you with that warm fuzzy feeling.
Thank you again Lars for the code.....
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
192 is 11000000
According to the PLC manual (wow, thats changed already! You guys are fast) thats 1 for start bit, 1 for the MSB of the channel bits (apparently the ADC channels connected are not 0-3 but 4-7), 00 to select the analog channel (00 = channel 4). So you're connecting the sensor to channel 4?
I also see internal timer is being used again but the pause·apparently gives it enough time to complete a conversion.
·
That's correct
The debug reads DEBUG " ADC1=",SDEC adresult, "mV ",CR But the input # on the PLC is 4
There is the same magic on the input and output #'s However there is a piece of code in the manual that corrects that, but it uses valuable space.
Post Edited (Cheese) : 3/5/2008 4:03:37 AM GMT