"Smalltalk is a vision of the computer as a medium of self expression. ... A humanistic vision of the computer as something everyone could use and benefit from. If you are going to have a medium for self expression, programability is key because unless you can actually make the system behave as you want you are a slave to what's on the machine. So it's really vital, and so language comes to the for because it's through language that you express yourself to the machine." -- Elliot Miranda

PIC/Smalltalk

Last Updated (Sunday, 14 February 2010 19:18)     |    Written by Administrator     |    Monday, 24 March 2008 22:46

Attention: open in a new window. PDFPrint

FAQs - Frameworks, Platforms & Tools

More ...

PIC/Smalltalk allows to write code for the PIC microcontroller in Smalltalk and then translate it to assembler.
The real project behind this tool is to build a fairly complex autonomous underwater vehicle (AUV), called Micro Seeker. This sub will use PIC microcontrollers for brains, and the language used to program a PIC is pretty annoying to use. So, the decision was to do something similar to what Squeak does for its VM, and write code in a Smalltalk-like syntax that is translated into assembler source code, and then assembled and run on the end platform.

MicroSeeker PIC/Smalltalk Example
First, here's the Smalltalk code, the method processServo in class PICServoInterface:

processServos
"Process the servo. Basically, servos work using pulse-width
modulation, where the frequency is about 50 Hz, and the duty
cycle determines the servo position. The duty cycle should be
between approximately 1000 and 2000 micro-seconds, although
different servos may require different duty cylces. These ones
in particular have a duty cycle between about 690 and 1690 us."

"Turn on the port to start with, and wait the initial 1 ms."
ServoPort setBit: Servo1Pin.
self servoDelay: 195.

"Now count down, doing a comparison on each interation. When
the count is equal to the servo's position, turn off the port."

servoCounter := 250.
[
self clearWatchdogTimer.
servoCounter = servoOnePosition
ifTrue: [ServoPort clearBit: Servo1Pin]]

repeatWhile: [servoCounter decrementSkipIfZero].

ServoPort clearBit: Servo1Pin

And now, the PIC assembler produced:

; ==========================================
; = processServos
; ==========================================
processServos equ *
bsf ServoPort, Servo1Pin
; Generating call to 'servoDelay:'
movlw 195
; Pushing WReg (next two instructions)...
decf indirectAddressLatch
movwf indirect
call servoDelay
; Popping (and ignoring) 1 variable from the stack...
incf indirectAddressLatch
movlw 250
movwf servoCounter
Label_00 equ *
clrwdt
movfw servoOnePosition, w
xorwf servoCounter, w
btfsc status, Zero
bcf ServoPort, Servo1Pin
decfsz servoCounter
goto Label_00
bcf ServoPort, Servo1Pin
return

For more information and source please go to the official site.


blog comments powered by Disqus

Login


If you don't want to register in this site, you can use your Gmail or OpenId authentication.



Smalltalk on Twitter

Fallingnephilim (Falling Nephilim) : #superspezialfollow goes to a very nice sweettweet always up for a nice smalltalk #FF now @DarkEnigma17

BoT_smalltalk24 (smalltalk-24) : - schau mal - www.smalltalk-24.de RT @ilkerde (Ilker Cetinkaya):@lennybacon macht session und #smalltalk gleichzei... http://bit.ly/bQH1nJ

BoT_smalltalk24 (smalltalk-24) : - schau mal - www.smalltalk-24.de RT @BruJUG (Brussels Java UG):Thank you very much for this great evening (and 3r... http://bit.ly/948NjC

BoT_smalltalk24 (smalltalk-24) : - schau mal - www.smalltalk-24.de RT @john_ababa (鬱金色の堕天使):Smalltalkとか俺と先生しか流行ってねーじゃんw: Smalltalkとか俺と先生しか流行ってねーじゃんw http://bit.ly/dpfhJk

Paypal Donation

Please, make a Paypal donation at least of 1 dollar! Thanks!

AddThis Feed Button