Sharing Variables tru Diferent COg,s SHT-11 sensiron sensor help . can't get the VAR'
Igor_Rast
Posts: 357
Im trying again to get the variables from anther cog.
wanted to let another cog run the program to get the temp and Rh measurements,
if I run it in a single Cog all goes Ok , if ill try to split it up so I can have one cog taking the readings.
and the main cog just looks at the varables and displays them on the LCD,
this because the main cog is handeling more processes and it gets a bit slow if i let the same cog do the reading .
hope someone could point out where my code goes wrong ,
im getting only a 0 display
igor
wanted to let another cog run the program to get the temp and Rh measurements,
if I run it in a single Cog all goes Ok , if ill try to split it up so I can have one cog taking the readings.
and the main cog just looks at the varables and displays them on the LCD,
this because the main cog is handeling more processes and it gets a bit slow if i let the same cog do the reading .
hope someone could point out where my code goes wrong ,
im getting only a 0 display
igor
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 RS = 25 {lcd control} RW = 26 {lcd control} E = 27 {lcd control} DBLow = 0 {lcd control} DBHigh = 3 {lcd control} SHT_DATA = 13 ' SHT-11 data pin SHT_CLOCK = 15 ' SHT-11 clock pin CLS = $0 ' clear screen CR = $D ' carriage return Deg = $B0
OBJ LCD : "LCD_20x4" {LCD controler} debug : "FullDuplexSerial" sht : "Sensirion_full" fp : "FloatString" f : "Float32" SN : "Simple_Numbers" VAR long stack1[128],idx,tc byte nstr[64] word tempC1,tempC2,tempC3,rh1,rh2,rh3
PUB Main f.start LCD.Init( E, RS, RW, DBHigh, DBLow ) LCD.usDelay( 5_000 ) LCD.Clear cognew(tempcontrol,@stack1) repeat print_temp waitcnt(clkfreq + cnt)
PUB print_temp LCD.RawSetPos( $1C ) LCD.PrintStr(tempC2) LCD.PrintStr( string(" C" )) LCD.RawSetPos( $5C ) LCD.PrintStr( rh2 ) LCD.PrintStr( string(" %" )) return
PUB tempcontrol sht.start(14,15) f.start repeat tempC1 := celsius(f.FFloat(sht.readTemperature)) {floating point raw measurement temp} tempC2 := fp.FloatToFormat(tempC1, 2, 0) { string for the display} tempC3 :=f.FTrunc(tempC1) { integer to calculate/use } rh1 := humidity(tempC1, f.FFloat(sht.readHumidity)) {floating poitn ram measurement RH } rh2 := fp.FloatToFormat(rh1, 2, 0) { string for the display} rh3 :=f.FTrunc(rh1) waitcnt(clkfreq + cnt)
Comments
keep the questions coming
best regards
Stefan
OK ,so there the Archive file .
ive changed the word to a long , now it gets the values, but i get or temp printed to both temp and rh or the other way around .
they overlap or somthing .
what im tring to get is a program so I can ready multiple sensors and store the values to use them , so 2 sensor's
the sensors share the clock line , and both have a independant data line
hope this is enough info to get the problem sorted
hope to hear soon
igor
made the changes , but it doen's realy do that , tha display value is nog good
Ideally you just store temperature and humidity as is and let the display code do the conversion (which voids the requirement for separate buffers). Meaning your display code will look something like this:
the buffer issue was indeed the probem , anyway
thanks allot for the help , sure helped me out
I was wondering if maybe you had any advise info on how to create a frequentie controler with the propeller to control a single fase 230 volt ac motor ,
sniffing around for some time but can't anyhing concrete to replicate or so . maybe you got any ideas
igor
where im there and I get stuck again , ill give you a peep
THANKSS