Discussion forum for the BasicX family of microcontroller chips.
|
On page 9 of "Basic Express Language Reference" v2.1, it says: "When you call a procedure, the Call keyword is optional. If Call is omitted, the parentheses around the actual parameters (if any) must also be omitted." I have found this to be only partially true. When the call is a System Library function (at least some of them), the compiler complains if you omit the Call but use parentheses. The message that it gives is "Missing right parenthesis" which is quite unhelpful. (Being a C/C++ programmer, I often leave off the Call so I see this message a lot. When I see "Missing right parenthesis" I now automatically think "Missing Call keyword". If you actually do leave off the right parenthesis on a Call, the error message is "Syntax error".) Here is some example code: Sub Main() ' the third statement compiles correctly, contrary to the doc Call foo(1) foo 1 foo(1) ' the third statement gives an error, as stated in the doc Call PutPin(12, bxOutputLow) PutPin 12, bxOutputLow PutPin(12, bxOutputLow) End Sub Sub foo(ByVal p as Byte) End Sub |
|
|
|
From: Don Kinzer <> > On page 9 of "Basic Express Language Reference" v2.1, > it says: > > "When you call a procedure, the Call keyword is optional. > If Call is omitted, the parentheses around the actual > parameters (if any) must also be omitted." > > I have found this to be only partially true. [...] Yes, there's a bug in the compiler. We need to work on it. BTW this is a VB6 compatibility thing, in case you're wondering about the rather strange rule. My memory is a bit fuzzy on the details, but I believe the compiler originally required both "call" and parentheses. Customers requested more flexibility, so we allowed call-less calls in a later version of the compiler. VB.NET now requires parentheses around all parameters, with or without "call", just to muddy the waters some more... -- Frank Manning -- NetMedia, Inc. |
|
Hello All, I was trying to write some code to an LCD, which required a stream of data. PutQueue won't allow me to pass a constant as a reference. I really did not want to define 20+ variables, so I decided to try loading in an array from a text file Using the example on page 6 of "Basic Express OS Reference" - Here is part of my code: ' Define Variables Const InputBufferSize As Integer = 10 '1-byte dummy Dim ICom(1 To InputBufferSize) As Byte Public OutBufferRW As New ByteVectorDataRW Call OutBufferRW.Source("D:\Heart.txt") When I try to compile I get errors: In line 4 "Public" or "Private" give me a Sytax Error. "Dim" - Vector/Table Data can't be local - must be module level. My first impression is the catch "must be declared at module level". - I had to open a module before I begin writing code, so my impression is that I am declaring it at module level. I know that there is probably a better way to do what I a doing, so please share away. However, I still need to learn about including a file for a future project. On the topic of BX24 vs. BS: For me, I have had to do quite a bit more studying to learn the BX24 than the Stamp. BasicX is fussy (see above). Their help files are great and most folks can write code for it within a short amount of time. After helping my buddy program his stamp, I reassured myself that this is worth it - Even if I can barely program the BX24. Thank you in advance for all of your input, Thad __________________________________ |
|
|
|
Hi Thad! First off, the file D:\Heart.txt is on yout PC, not on the BX, so at run time it can't "see" it. You can include a file, but that file is supposed to be written in BasicX. There are several ways you can load an array or string to use in your program. You could simple have a line like: Dim s String s = "whatever you want to send to the LCD" or you could use something like: Dim S(1 to 20) s(1) = 32 s(2) = 48 s(3) = 52 and so on... As for the syntax errors, unless you need the variable to be visible in other modules or functions, or in a task, you don't need to declare them as public. Without seeing all of the code, some of the errors don't make enough sense to understand why you're getting them. Maybe someone else on the list can shed some light... Sloan ----- Original Message ----- From: "Thad Larson" <> To: <> Sent: Saturday, April 24, 2004 10:23 AM Subject: [BasicX] Still fuzzy about modules...maybe?? > Hello All, > > I was trying to write some code to an LCD, which > required a stream of data. PutQueue won't allow me to > pass a constant as a reference. I really did not want > to define 20+ variables, so I decided to try loading > in an array from a text file > > Using the example on page 6 of "Basic Express OS > Reference" - Here is part of my code: > ' Define Variables > Const InputBufferSize As Integer = 10 '1-byte dummy > Dim ICom(1 To InputBufferSize) As Byte > Public OutBufferRW As New ByteVectorDataRW > Call OutBufferRW.Source("D:\Heart.txt") > > When I try to compile I get errors: > In line 4 "Public" or "Private" give me a Sytax Error. > "Dim" - Vector/Table Data can't be local - must be > module level. > > My first impression is the catch "must be declared at > module level". - I had to open a module before I > begin writing code, so my impression is that I am > declaring it at module level. > > I know that there is probably a better way to do what > I a doing, so please share away. > However, I still need to learn about including a file > for a future project. > On the topic of BX24 vs. BS: For me, I have had to do > quite a bit more studying to learn the BX24 than the > Stamp. BasicX is fussy (see above). Their help files > are great and most folks can write code for it within > a short amount of time. After helping my buddy > program his stamp, I reassured myself that this is > worth it - Even if I can barely program the BX24. > > Thank you in advance for all of your input, > Thad > > > __________________________________ > > > Yahoo! Groups Links > -- > Incoming mail is certified Virus Free. > Checked by AVG Anti-Virus (http://www.grisoft.com). > Version: 7.0.230 / Virus Database: 262.9.5 - Release Date: 4/23/2004 |
|
--- In , Thad Larson <highwayman_33402@y...> wrote: > I was trying to write some code to an LCD, which > required a stream of data. PutQueue won't allow me to > pass a constant as a reference. I really did not want > to define 20+ variables, so I decided to try loading > in an array from a text file ... One point to mention about ByteVectorDataRW and related types is that they have a limited write-cycle lifetime. These types are located in the BX-24's program memory so the write cycle limitations are the same as for PutEEPROM(), q.v. You might consider writing a group of functions to write data to the LCD beginning at the "current position". Other functions should be written to set the current position, thus allowing you to display information whereever you want. One of the display functions would take an address in EEPROM and write a sequence of characters found there to the LCD. You can either terminate strings with a zero byte or code them in the EEPROM so that the first byte gives the number of characters in the string. This function, then, allows you to display fixed (i.e. non-changing) strings. Another set of functions could be designed to display byte, integer and single values at the current position on the LCD. You could also add the capability to apply some formatting the the output, e.g. left- , right- and center-justification. Another function could be written for string values. With such a set of functions, you may find that you don't need the 20+ bytes of variables that you mentioned. |
|
|
|
I'll shortly need to stabilize a device so that it remains within a few degrees of horizontal at all times on a pitching (+/- 10 degrees) and rolling (+/- 20 degrees) vehicle. The device is PDA-sized and will be gimballed. We see two approaches: using true flywheel gyros for most of the work with servo assistance to correct initial error and precession, or to actively steer a motor-gimbal platform with electronic horizon sensing. Any suggestions of these or a better method? Tom Tom Becker --... ...-- www.RighTime.com The RighTime Clock Company, Inc., Cape Coral, Florida USA +1239 540 5700 |
|
|
|
Hi Tom, I believe Kyonix has a 3-axis accelerometer with a 2g range, more than adequate for sensing tilt. The hardest problem would be to decide on sensitivity versus noise. I have one working which measures good changes to within 0.2 degrees. I have used the Kyonix 2 axis one, and the best part is that you don't need to calibrate it, it always reads 0.5 of the input voltage when level - only temperature can affect the output, and this can also be compensated for. Regards, Mike ----- Original Message ----- From: "Tom Becker" <> To: <> Sent: Saturday, April 24, 2004 7:14 PM Subject: [BasicX] Gyro'd platform > I'll shortly need to stabilize a device so that it remains within a few > degrees of horizontal at all times on a pitching (+/- 10 degrees) and > rolling (+/- 20 degrees) vehicle. The device is PDA-sized and will be > gimballed. > > We see two approaches: using true flywheel gyros for most of the work > with servo assistance to correct initial error and precession, or to > actively steer a motor-gimbal platform with electronic horizon sensing. > > Any suggestions of these or a better method? > Tom > > Tom Becker > --... ...-- > www.RighTime.com > The RighTime Clock Company, Inc., Cape Coral, Florida USA > +1239 540 5700 > Yahoo! Groups Links |
|
|
|
> ... Kionix has a 3-axis accelerometer ... I have one working which measures good changes to within 0.2 degrees... Thanks for the pointer. After studying those products I was, inevitably I suppose, brought back to the ADXL311. I'm having some trouble, though, finding any data on the required analog gain to get to the noise floor. It looks to me that the ADXL311 yields a signal too small for direct conversion to 10-bits/5volts with any useful resolution. If I want to level a platform - let's say on a stationary mount at sea level on Earth - what gain is pragmatically required to make best use of the device signals in 10-bits? Tom Tom Becker --... ...-- www.RighTime.com The RighTime Clock Company, Inc., Cape Coral, Florida USA +1239 540 5700 |
|
|
|
Hi Tom, The ADXL311 will output 2.5 volts (assuming 5.0 volt supply, make sure your supply is as clean as possible - a series resistor of 100 ohms in the supply track helps too) when level. With a 10-bit ADC, you will be getting a resolution of 4.88mV. If you were to turn 90 degrees, you would be dropping or gaining the 2.5V, so in effect, the output would change (linearly, more on this later) by 27.7mV every degree of tilt. Thus, you can read (approximately) a change of 0.17 degrees. Now, in the real world (you can do this in the lab with very nice gear, no noise, vibration, etc. etc.) you will be getting worse resolution, due to the aforementioned factors. There are a couple of appnotes in the Analog site that deal with this - a particularly interesting one is the car alarm, as it talks in depth about filter settings so that you get the bandwidth and noise floor you are looking for. As a final tip, heat is a problem, rapid changes can affect the reading - a nice big blob of silicone on top of the ADXL helps a bit. Let me know if you need more info, I've been playing with these critters for the past two years :-) Regards, Mike ----- Original Message ----- From: "Tom Becker" <> To: <> Sent: Sunday, April 25, 2004 7:28 PM Subject: RE: [BasicX] Gyro'd platform > > ... Kionix has a 3-axis accelerometer ... I have one working which > measures good changes to within 0.2 degrees... > > Thanks for the pointer. After studying those products I was, inevitably > I suppose, brought back to the ADXL311. I'm having some trouble, > though, finding any data on the required analog gain to get to the noise > floor. It looks to me that the ADXL311 yields a signal too small for > direct conversion to 10-bits/5volts with any useful resolution. > > If I want to level a platform - let's say on a stationary mount at sea > level on Earth - what gain is pragmatically required to make best use of > the device signals in 10-bits? > Tom > > Tom Becker > --... ...-- > www.RighTime.com > The RighTime Clock Company, Inc., Cape Coral, Florida USA > +1239 540 5700 > > Yahoo! Groups Links |
|
|
|
> ... The ADXL311 will output 2.5 volts [] when level... If that's so it's a perfect interface, but that's not what I think I'm reading in the ADXL311 spec, Mike. It indicates that zero g is typically indicated by +1.5v, and its sensitivity is about 167mV per g, i.e. 0.334v fullscale for tilt. To convert that to 0-5v, it looks like I need a DC offset of +1v and DC gain of about 15. Is it the Kionix module that yields 0-5v with 2.5v when level? Tom Tom Becker --... ...-- www.RighTime.com The RighTime Clock Company, Inc., Cape Coral, Florida USA +1239 540 5700 |
|
You not only need an accelerometer, you also need a gyro and a filter (like the kalman filter) to get a real current angle without drift and be successfull in balancing in long term... For the accels, yes you do need an OPAMP, check out : www.rotomotion.com, they make good ready to go boards with gyros and accels, you can ether buy the sensor board or sens board + ctl board... I recommend the sensor board and interface with BasicX... You could also measure duty cycle to get inclination from your accel. But be ware that under linear acceleration, accelerometers no longer report angle, and your angle reading will not be faithfull.. Check out my project page : www.fusionglobal.net, its a two wheel balancing robot using a gyro and accel. Code and schematics are available there for open source. Good luck, if i can help let me know. |
|
|
|
Output Capture may be somewhat of a misnomer, but it works just great. I am limited by the fact that there is but 1 output line and I need to talk to 4 lines. For the 1 line I use pin 18 to drive a transistor that pulses the line. I was thinking about using an AND gate and putting the output capture pulses on all 4 lines and then using the AND gate to determine which of the 4 transistors actually received the changed states. pin 18 -- AND enable line 1 -- to driver transistor for line 1 pin 18 -- AND enable line 2 -- to driver transistor for line 2 ... Whichever line was enabled would be High and the output of the AND would follow the pin 18. The other line would remain Low. Does this make sense? Is there another (better?) way? Thanks, Bob Roos |
|
|
|
--- In , Bob Roos <roosbob@w...> wrote: > [...] > I was thinking about using an AND gate and putting the output > capture pulses on all 4 lines and then using the AND gate to > determine which of the 4 transistors actually received the > changed states. This is a perfect application for a demultiplexer. Take a look at the 74xx139. Its a dual 1-to-4 decoder/demultiplexer that has an active low enable. Sounds like you'll only need 1/2 of the package. If you feed your "select code" to the A and B inputs from two BX outputs and then feed your data out from the BX to the enable (G), one of the four outputs will reproduce your data stream while the other three remain high. Depending on what you're driving, you may need another level of inversion on the decoder output. Or, just invert the data stream out of the BX to accomplish the same effect. |
|
|
|
Don, this is exactly what I was looking for on output. Now comes the question of input. Each of these 4 lines may respond with pulses, but they only speak when spoken to and only immediately after spoken to. I have only 1 pin (Input Capture) to get the pulses. I need some sort of a "funnel" to the input capture pin. Perhaps ANDing all 4 lines together will give me what I need because 3 of the lines will be high and one will be varying. I originally thought I needed to know that the varying line was line X but as I think about it I am not so sure. If the only line that could have anything on it is the one I just spoke to then maybe that is sufficient. If the output used a Decoder/Demultiplexer is there a Coder/Multiplexer for the input? Glad I asked, I Googled it and found there are such things! A search on DigiKey gives me a TI CD54HC153 4 input mux. I really appreciate the help here. Thanks. Bob On Mon, 26 Apr 2004 14:46:35 -0000, Don Kinzer <> wrote: > --- In , Bob Roos <roosbob@w...> wrote: >> [...] >> I was thinking about using an AND gate and putting the output >> capture pulses on all 4 lines and then using the AND gate to >> determine which of the 4 transistors actually received the >> changed states. > > This is a perfect application for a demultiplexer. Take a look at > the 74xx139. Its a dual 1-to-4 decoder/demultiplexer that has an > active low enable. Sounds like you'll only need 1/2 of the package. > > If you feed your "select code" to the A and B inputs from two BX > outputs and then feed your data out from the BX to the enable (G), > one of the four outputs will reproduce your data stream while the > other three remain high. Depending on what you're driving, you may > need another level of inversion on the decoder output. Or, just > invert the data stream out of the BX to accomplish the same effect. |
|
|
|
--- In , Bob Roos <roosbob@w...> wrote: > [...] is there a Coder/Multiplexer for the input? > > Glad I asked, I Googled it and found there are such things! > A search on DigiKey gives me a TI CD54HC153 4 input mux. Indeed. A multiplexer is an ideal way to expand the BX's input capacity. Of course, since only one input at a time is logically connected to the BX, you can't use it for a set of inputs where you need to read more than one at a time. You no doubt realize that the same two BX output lines to select the input "channel" and the output "channel". Or, you could select them independently. |