CONSTANTS in Oshonsoft

Thread Starter

camerart

Joined Feb 25, 2013
3,559
Hi,
I'm using an 18F4431, and Oshonsoft BASIC.

Is it possible to have 'say' a WORD variable as a CONSTANT?
Camerart.
 

ericgibbs

Joined Jan 29, 2010
18,024
hi C,
The manual says yes.
In what way are you using the Constant and why.?
E

Const,
Constants can be assigned to symbolic names using CONST directive. Constants can be global or local. One example:
Dim x As Single
Dim y As Word
Const pi = 3.14159
Const high = 1023
x = pi
y = high
 

Thread Starter

camerart

Joined Feb 25, 2013
3,559
hi C,
The manual says yes.
In what way are you using the Constant and why.?
E

Const,
Constants can be assigned to symbolic names using CONST directive. Constants can be global or local. One example:
Dim x As Single
Dim y As Word
Const pi = 3.14159
Const high = 1023
x = pi
y = high
Hi E,
A member on ETO has kindly written some 'C' CODE for me, which relates to an earlier question here.

This is one of the lines, used: ['Const frame = 20000 'how long each frame is]
This doesn't compile, so I changed it to a DIM with 2x BYTES, but it would be interesting to know if CONST is possible.
C
 

ericgibbs

Joined Jan 29, 2010
18,024
hi C,
You can declare Frame as a Const but OSH will not let you split it as HB, LB for later processing.
E

Query:
Is this the Servo 20Sec Frame time, if so, why do you want to Compare with it CCPR1.?
When a CCPR1 Flags the equality of the CCPR1 with the Timer.?
E
EG57_ 526.png
 

Thread Starter

camerart

Joined Feb 25, 2013
3,559
hi C,
You can declare Frame as a Const but OSH will not let you split it as HB, LB for later processing.
E

Query:
Is this the Servo 20Sec Frame time, if so, why do you want to Compare with it CCPR1.?
When a CCPR1 Flags the equality of the CCPR1 with the Timer.?
E
View attachment 286463
Hi E,
RE: CONSTANTS, OK.

I'm having difficulty understanding quite what this program does. FRAME may have changed from 20ms to a much faster time, from what I undertsand, it is clocking BYTES in 'US' with an INTERRUPT from SERVOS and the GPS UART.
C
 

jjw

Joined Dec 24, 2013
816
Hi E,
A member on ETO has kindly written some 'C' CODE for me, which relates to an earlier question here.

This is one of the lines, used: ['Const frame = 20000 'how long each frame is]
This doesn't compile, so I changed it to a DIM with 2x BYTES, but it would be interesting to know if CONST is possible.
C
Const Frame=20000
compiles.
Edit: You found it already.
 

jjw

Joined Dec 24, 2013
816
Hi E,
RE: CONSTANTS, OK.

I'm having difficulty understanding quite what this program does. FRAME may have changed from 20ms to a much faster time, from what I undertsand, it is clocking BYTES in 'US' with an INTERRUPT from SERVOS and the GPS UART.
C
When I looked the latest version in ETO, the frame time was counted using 1ms interrupts.
I don't know, if the frame time should be exactly 20ms, but it can reached for example by making one extra interrupt with time of 20ms-sum of servo interrupt times.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,559
Hi,
Do you have a datasheet for the Servo, the usual Frame is 20mSec.
E
Hi E,
I have many SERVOS, they all work from ESCs, and have the 20ms 'FRAME', but I think this is different, it is all hardware, and I had to buy and place a 'shift register' onto a separate PCB, with 2x inputs, for this to work.
C
 

jjw

Joined Dec 24, 2013
816
Hi E,
I have many SERVOS, they all work from ESCs, and have the 20ms 'FRAME', but I think this is different, it is all hardware, and I had to buy and place a 'shift register' onto a separate PCB, with 2x inputs, for this to work.
C
You had a test program, which worked alone without jitter, but with the full program it had jitter.
Did you find the reason for the jitter?
 

Thread Starter

camerart

Joined Feb 25, 2013
3,559
You had a test program, which worked alone without jitter, but with the full program it had jitter.
Did you find the reason for the jitter?
Hi J,
Yes, it was agreed that SW CODE will jitter, so it has to be done in HW.
C
 

Thread Starter

camerart

Joined Feb 25, 2013
3,559
hi C,
I have no intention on ever going over to ETO.:rolleyes:

E
Hi E,
I remember why!
Here's the timing explanation:
C
------------------------------------------------
The chip can execute 8,000,000 (assuming 32MHz) instructions per second. The ISRs just take it in turn to do their thing. They've got 1mS (8000 instructions) between each byte arriving from the GPS. Same for each servo and the timer interrupt takes just a few instructions every 8,000 instructions. Oodles of time.
----------------------------------------------------------------
 

ericgibbs

Joined Jan 29, 2010
18,024
hi C,
I assume the Servo get the usual 1mSec thru 2mSec positioning pulse every 20mSec frame period.?
How are you varying the positioning pulse period.?
E

BTW: please post here on AAC any technical data being referred too in your posts.

OT:
I hope your project gets completed in my lifetime, I am in my 91st year!
 

Thread Starter

camerart

Joined Feb 25, 2013
3,559
hi C,
I assume the Servo get the usual 1mSec thru 2mSec positioning pulse every 20mSec frame period.?
How are you varying the positioning pulse period.?
E

BTW: please post here on AAC any technical data being referred too in your posts.

OT:
I hope your project gets completed in my lifetime, I am in my 91st year!
Hi E,
Yes, each SERVO get 1 to 2ms, but if I understand correctly, not in 1x burst. I think it is a much faster pulse, which adds up to 1- 2ms. A bit like dimming an LED. I'm going to stop and have a think, and prints strips of paper with 32mHz square wave, join them together, and see ff I can visualise how it works. There are other proposals too.

The technical data is only the 18f4431 D/S and OSH rules.

I hope I finish the project in my lifetime too, I hope to have something at least taking off this years, let's hope so.

Well done for your many helps, for me and the other members, thanks. (not forgetting lots of tolerance for us dunces :) )
C
 
Last edited:
Top