Hello guys, thank you so much for your interest in helping me with this issue, I have actually tried serveral things but I still get the same problem.
Pressure5 is declared as a single
Plow and Phigh are also declared as single variables
I tried using Select Case, but I still have the same issue, this time if I Plow is = 40psi and Phigh = 50Psi It seems like it only loops through the Case is <Plow no matter if the presssure is higher or in between.
this the new code section for that part
[code:1:2262c8d157]Do
Start Adc
Voltage = Pressure / Fullrange
Voltage1 = Voltage * Ref
Pressure1 = Voltage1 - Intercept
Pressure2 = Pressure1 / Slope
Pressure3 = Pressure2 - Voltage4
Pressure4 = Fusing(pressure3 , "#.##")
Pressure5 = Val(pressure4)
Ipressure = Pressure5
Disable Serial
Print "Pressure levels " ; Iplow ; " " ; Iphigh
Enable Serial
Waitms 20
Select Case Ipressure
Case Iplow To Iphigh
Disable Serial
Print "Pressure 5 " ; Ipressure
Incr I
Print "first"
Enable Serial
Shiftout Pinout , Srclk , Dataon , 1
Reset Portd.2
Set Rclk
Waitms V
Reset Rclk
Shiftout Pinout , Srclk , Dataoff , 1
Set Portd.2
Set Rclk
Waitms W
Reset Rclk
Disable Serial
Print "Stroke Number 1" ; I ; " " ; "Pressure: " ; Pressure4 '; Chr(13); 'display current stroke number on hyperterminal
Enable Serial
Qualified = I
Case Is > Iphigh
Incr I
Incr J
Shiftout Pinout , Srclk , Dataon , 1
Reset Portd.2
Set Rclk
Waitms V
Reset Rclk
Shiftout Pinout , Srclk , Dataoff , 1
Set Portd.2
Set Rclk
Waitms W
Reset Rclk
Disable Serial
Print "Stroke Number 2 " ; I ; " " ; "Pressure Is Higher: " '; Pressure4 ; Chr(13); 'display current stroke number on hyperterminal
Enable Serial
Unqualified3 = J
Case Is < Iplow
'Elseif Pressure5 < Plow Then
Incr I
Incr H
'Print "third"
Shiftout Pinout , Srclk , Dataon , 1
Reset Portd.2
Set Rclk
Waitms V
Reset Rclk 'On time set by W variable
Shiftout Pinout , Srclk , Dataoff , 1
Set Portd.2
Set Rclk
Waitms W
Reset Rclk
Disable Serial
Print "Stroke Number 3 " ; I ; " " ; "Pressure Is Lower: " ; Pressure4 ; " " ; Iplow ; " " ; Iphigh 'display current stroke number on hyperterminal
Enable Serial
Unqualified4 = H
'End If
End Select
Loop Until Buf = "terminate"[/code:1:2262c8d157]
Maybe I should mention that I have an two interrupts going, one to capture any serial characters and another one to capture the conversion from the ADC i don't know if any of this interrupts have anything to do with it but here's the code for that
[code:1:2262c8d157]Rec_isr:
D = Udr 'read UDR only once
'Print "*" ' show that we got here
If Bc < Cmaxchar Then 'does it fit into the buffer?
Incr Bc 'increase buffer counter
'Incr Devices
If D = 13 Then 'return?
Buf = Buf + Chr(0)
Bc = Cmaxchar 'at the end
Else
Buf = Buf + Chr(d) 'add to buffer
End If
End If
B = 1 'set flag
Return[/code:1:2262c8d157]
And here is the interrupt for the ADC
[code:1:2262c8d157]Getpressure:
Pressure = Getadc(0)
Return[/code:1:2262c8d157]
Obviously this is the code at the beginning where I define the ISRs
[code:1:2262c8d157]On Urxc Rec_isr
On Adc Getpressure
Enable Adc
Enable Urxc
Enable Interrupts[/code:1:2262c8d157]
I'm really bothered at the fact that i can't figure out what's going on, I even tried changing the variables from single to Integers but still the problems persists.
What do you guys think?
Thanks,
Walter
↧