Hi
I want to use SUBroutine with single values, but compiler reports error, why ?
Error: GCASM: Symbol [SFR]SYSMULTSUBSINGLE has not been defined. Inspect ASM file to determine error at CALL SYSMULTSUBSINGLE Hexfile address(see lst file): 000148
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Variables Kp ,Ku,Ki ,Kd ,Setpoint ,Integral , Previouserror,Pot1 are global
sub Autotune
dim petla as word
' Setpoint = 800
' Integral = 0
' Previouserror = 0
' Ku = 0
' Tu = 0
For petla = 1 To 100 Step 1
Output1 = 0
PWM1_Duty = Output1
Pot1 = ReadAD10(AN0)
Wait 100 us
Tu = Tu + 1
Setpoint_tmp = Setpoint + 10
If Pot1 > Setpoint_tmp Then Exit For
Next
kp = petla
Kp = 0.6 * Ku Ki = 2 * Kp / Tu
Kd = Kp * Tu / 8
End Sub
Last edit: Boguslaw 2024-01-18
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Attached code. I have one problem yet, PWM don't work can you see why ?
I noticed that the problem is not in SUB, when I remove SUB the error is still there.
, problem is caused by this line: Output1 = Kp * Error + Ki * Integral + Kd * Derivative
I changed all variables to single and without effect.
How to perform mathematical operations with single variables?
There are many PWM demos. Work out which one you need to use - i would recommend PWM/CPP as this is the easy one. There more demos on 16bit demos in the demo folders.
if I use specific numbers, I understand, but when I multiply two single variables,
single1=single2*single3 s(ingles 2 and 3 calculated in another part of the program)
I don't know how to solve it.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
I want to use SUBroutine with single values, but compiler reports error, why ?
Error: GCASM: Symbol [SFR]SYSMULTSUBSINGLE has not been defined. Inspect ASM file to determine error at
CALL SYSMULTSUBSINGLE
Hexfile address(see lst file): 000148Hello,
Post your program so I see the error. Please attach to your post.
Variables Kp ,Ku,Ki ,Kd ,Setpoint ,Integral , Previouserror,Pot1 are global
Last edit: Boguslaw 2024-01-18
This not the complete program, so, I cannot try to compile.
But,
Kp = 0.6 * Ku
is probably the issue. You need to factorise to use integer calculations.Attached code. I have one problem yet, PWM don't work can you see why ?
I noticed that the problem is not in SUB, when I remove SUB the error is still there.
, problem is caused by this line: Output1 = Kp * Error + Ki * Integral + Kd * Derivative
I changed all variables to single and without effect.
How to perform mathematical operations with single variables?
Last edit: Boguslaw 2024-01-18
I would look at the demos for Q71.
C:\GCstudio\gcbasic\demos\Vendor_Boards\Great_Cow_Basic_Demo_Board\18f26q71_chiprange_demonstrations
There are many PWM demos. Work out which one you need to use - i would recommend PWM/CPP as this is the easy one. There more demos on 16bit demos in the demo folders.
Regarding singles ( we called the Floats) , see https://sourceforge.net/p/gcbasic/discussion/596084/thread/b867317011/
Use factorised integers. They work a lot lot faster and they work.
if I use specific numbers, I understand, but when I multiply two single variables,
single1=single2*single3 s(ingles 2 and 3 calculated in another part of the program)
I don't know how to solve it.
Read the https://sourceforge.net/p/gcbasic/discussion/596084/thread/b867317011/ post?
Remove the SINGLES from you program and use factorised integers.
Then, the maths will work.