BX-24 For Next Error

Started by gouardopatrick January 31, 2009
Hello,

I wrote the following program to read a value on the ADC Port and
convert it to RMS value.
I have an error at the line Next K and I cannot find the reasons.
Can someone help me to get out of this situation, I have little
experience with programming .
Thanks for your help.

Patrick.

'--------------------------------
Option Explicit

'--------------------------------
Public Sub Main()

'This program reads an 50 Hz AC Voltage connected to ADC pin 13 and
'try to find the RMS value of the I Current by looking at the Max
'The RMS value is the Max Value divided by 1.414 for a sine wave
'The voltage reading is 50 times to get the maximum but this
'value maybe changed later after tests
Dim N As Integer
Dim IAc As Single ' Ranges from 0.0 to 1.0.
Dim I As Single
Dim IMax As Single
Dim K As Integer
Const IAcPin As Byte = 13

Debug.Print
Debug.Print "Voltage/Current Measuring Example"
Debug.Print

Do
' Read nondimensional IAc Value.
For K = 1 To 50
IMax=5.5
Call GetAdc(IAcPin , IAc)
I= IAc*5.14
If (I > IMax) then
IMax = I
End If
Next K
Debug.Print CStr(I)

Loop

End Sub
'--------------------------------
Just put:
Next (instead of Next k)

David M.

----- Original Message -----
From: gouardopatrick
To: b...
Sent: Saturday, January 31, 2009 3:04 PM
Subject: [BasicX] BX-24 For Next Error
Hello,

I wrote the following program to read a value on the ADC Port and
convert it to RMS value.
I have an error at the line Next K and I cannot find the reasons.
Can someone help me to get out of this situation, I have little
experience with programming .
Thanks for your help.

Patrick.

'----------------------
Option Explicit

'----------------------
Public Sub Main()

'This program reads an 50 Hz AC Voltage connected to ADC pin 13 and
'try to find the RMS value of the I Current by looking at the Max
'The RMS value is the Max Value divided by 1.414 for a sine wave
'The voltage reading is 50 times to get the maximum but this
'value maybe changed later after tests

Dim N As Integer
Dim IAc As Single ' Ranges from 0.0 to 1.0.
Dim I As Single
Dim IMax As Single
Dim K As Integer
Const IAcPin As Byte = 13

Debug.Print
Debug.Print "Voltage/Current Measuring Example"
Debug.Print

Do
' Read nondimensional IAc Value.
For K = 1 To 50
IMax=5.5
Call GetAdc(IAcPin , IAc)
I= IAc*5.14
If (I > IMax) then
IMax = I
End If
Next K
Debug.Print CStr(I)

Loop

End Sub
'----------------------


Hello David,

Thanks for your reply and help.

You are right, removing the K for Next K make it working.

In fact I started without the K and had the problem.
Then I clear the code because I had other line not usefull for the
conversion and I forgot to remove the K .

Thanksq, I progress in my small project, things are going slowy but
surely, this make me happy and willing to go further.

Best Regards.

Patrick.
--- In b..., "David Sousa Mendes"
wrote:
>
> Just put:
> Next (instead of Next k)
>
> David M.
>
> ----- Original Message -----
> From: gouardopatrick
> To: b...
> Sent: Saturday, January 31, 2009 3:04 PM
> Subject: [BasicX] BX-24 For Next Error
> Hello,
>
> I wrote the following program to read a value on the ADC Port
and
> convert it to RMS value.
> I have an error at the line Next K and I cannot find the reasons.
> Can someone help me to get out of this situation, I have little
> experience with programming .
> Thanks for your help.
>
> Patrick.
>
> '----------------------
> Option Explicit
>
> '----------------------
> Public Sub Main()
>
> 'This program reads an 50 Hz AC Voltage connected to ADC pin 13
and
> 'try to find the RMS value of the I Current by looking at the Max
> 'The RMS value is the Max Value divided by 1.414 for a sine wave
> 'The voltage reading is 50 times to get the maximum but this
> 'value maybe changed later after tests
>
> Dim N As Integer
> Dim IAc As Single ' Ranges from 0.0 to 1.0.
> Dim I As Single
> Dim IMax As Single
> Dim K As Integer
> Const IAcPin As Byte = 13
>
> Debug.Print
> Debug.Print "Voltage/Current Measuring Example"
> Debug.Print
>
> Do
> ' Read nondimensional IAc Value.
> For K = 1 To 50
> IMax=5.5
> Call GetAdc(IAcPin , IAc)
> I= IAc*5.14
> If (I > IMax) then
> IMax = I
> End If
> Next K
> Debug.Print CStr(I)
>
> Loop
>
> End Sub
> '----------------------
>
>
>
>
>

Go for it!
I still consider Basicx's microcontroler to be very handy.
It's surely worth the effort!

David

----- Original Message -----
From: gouardopatrick
To: b...
Sent: Saturday, January 31, 2009 5:52 PM
Subject: [BasicX] Re: BX-24 For Next Error
Hello David,

Thanks for your reply and help.

You are right, removing the K for Next K make it working.

In fact I started without the K and had the problem.
Then I clear the code because I had other line not usefull for the
conversion and I forgot to remove the K .

Thanksq, I progress in my small project, things are going slowy but
surely, this make me happy and willing to go further.

Best Regards.

Patrick.

--- In b..., "David Sousa Mendes"
wrote:
>
> Just put:
> Next (instead of Next k)
>
> David M.
>
>
>
> ----- Original Message -----
> From: gouardopatrick
> To: b...
> Sent: Saturday, January 31, 2009 3:04 PM
> Subject: [BasicX] BX-24 For Next Error
>
>
> Hello,
>
> I wrote the following program to read a value on the ADC Port
and
> convert it to RMS value.
> I have an error at the line Next K and I cannot find the reasons.
> Can someone help me to get out of this situation, I have little
> experience with programming .
> Thanks for your help.
>
> Patrick.
>
> '----------------------
> Option Explicit
>
> '----------------------
> Public Sub Main()
>
> 'This program reads an 50 Hz AC Voltage connected to ADC pin 13
and
> 'try to find the RMS value of the I Current by looking at the Max
> 'The RMS value is the Max Value divided by 1.414 for a sine wave
> 'The voltage reading is 50 times to get the maximum but this
> 'value maybe changed later after tests
>
> Dim N As Integer
> Dim IAc As Single ' Ranges from 0.0 to 1.0.
> Dim I As Single
> Dim IMax As Single
> Dim K As Integer
> Const IAcPin As Byte = 13
>
> Debug.Print
> Debug.Print "Voltage/Current Measuring Example"
> Debug.Print
>
> Do
> ' Read nondimensional IAc Value.
> For K = 1 To 50
> IMax=5.5
> Call GetAdc(IAcPin , IAc)
> I= IAc*5.14
> If (I > IMax) then
> IMax = I
> End If
> Next K
> Debug.Print CStr(I)
>
> Loop
>
> End Sub
> '----------------------
>
>
>
>
>
>
>