Jump to content


Photo

programming in Basic


  • Please log in to reply
6 replies to this topic

#1 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 07:23 PM

Today I compiled X11-basic on pcDuino3 and thought that others might be interested. Many people got their start with the basic programming language. Next I plan to experiment with IO control, I2C, SPI, etc.


I followed these instructions and made adjustments as needed.


First install packages...


Code: [Select]
sudo apt-get install libreadline-dev tcsh libncurses5-dev xutils-dev libc6-dev libsdl1.2-dev libtool

Download version 1.22 source file. I was not able to get the newest version, 1.23, to compile successfully. Maybe someone else will have better luck.

Download source files.


Extract files


Code: [Select]
tar xvzf X11Basic-1.22.tar.gz

Change to the directory


Code: [Select]
cd X11Basic-1.22

Make directory


Code: [Select]
sudo mkdir -p /usr/local/share/man/man1

Configure, Make, and install


Code: [Select]
./configure
Code: [Select]
sudo make
Code: [Select]
sudo make install
modify_inline.gif
 
 

 



#2 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 07:23 PM

PDF manual for X11-Basic



#3 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 07:23 PM

I also got FreeBasic working. It seems to have a better method for using external C libraries. If I can convert the c_environment headers and figure out how to use them then GPIO control should be easy. Perhaps it would just be easier to write my own IO drivers.



#4 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 07:23 PM

I have achieved general IO control using X11 basic. Cycling a pin between high and low states using the least amount of code possible. Meaning not pretty code.  Running interpreted code I get about 8.5khz or 0.118ms. Compiled to native produces cycles at 12.0khz or 82.7us.


Edit: Arduino code produced 136.6khz or 7.32us


Seems like I have some work to do shocked.gif .



#5 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 07:23 PM

I compiled yaBasic and was able to achieve 44khz without any complex code.



#6 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 07:24 PM

Today I was able to use compiled C library in X11basic. I compiled the c_environment code to libarduino.so for use in x11basic.


Then I wrote this code to init gpio pins, set pinmode of pin 1 to output, and then raise and lower pin 1 with as little code as possible.

'Run init
link #1,"./c_environment/libarduino.so"
adr=SYM_ADR(#1,"init")
ret=call(adr)
'Set pinmode to output
adr=SYM_ADR(#1,"pinMode")
ret=call(adr,1,1)
' setup digitalWrite
adr=SYM_ADR(#1,"digitalWrite")
do
ret=call(adr,1,1)
ret=call(adr,1,0)
loop
unlink #1

Running this code from the interpreter produced switching as 17.4khz or 57.2us.
Compiled to a native program produced 41.2khz or 24.3us.


This matches what I was able to do with yaBasic and since it does not have the ability to access C libraries I do not see a way to improve it.


Using the compiled library should also give me access to SPI, I2C, etc. Time will tell.



#7 jim

jim

    Advanced Member

  • Administrators
  • 3,385 posts

Posted 13 February 2015 - 07:24 PM

Python produces approximately 84khz. Very surprising result. More research needed.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users