Help with Programming BAsic

Hi there, as above… funny how i have this LynxMotion Bot Board II in my hand but know nuts about programming…

Ok here’s the problem… It has the Basic Atom 28 chip.

I’m suppose to get the BB to churn out some automatic command to run some servos inside a temperature chamber.

But my programmer is uncontactable so I resort to my own hand… as you guess it… i messed up…

Can anyone help me with the program?

I need to run 2 sets of PWM to make these 2 servos perform 2 different rotating patterns…
Eg Pin 13 will make one servo ‘dance’ like a pendulum, swinging left to right (max position, JR servo) to left continuously…
Pin 14 will make the other servo ‘dance’ stepping from left to right to left at 1ms step with a pause of say 200ms in between each 1ms step.
But with each 5 cycles, I need Pin 15 to pull a high signal out then come back to low again after 200ms.

Can someone help me out please? Thanks…

Hello!

Your best bet is to learn the basic language and program this yourself. I doubt you will find someone on here willing to write a complete program to your specs, and had it over to you.

There are many “teach yourself basic” books that teach the fundamentals of the basic language and you can then take that knowledge and apply it to Mbasic or Pbasic depending on the MCU you want to use. Different MCUs (Micro Controller Units) use slightly different commands depending on the built in hardware they use among some other small differences.

Hi,

Many of us up here are willing to help out, but it may be hard to get someone to write a complete program for you.

But from your description it sounds like you have made some attempts. It might help to see what you have tried and a description of the results to date. You might start off with doing one servo, maybe using the pulseout command. It might look something like:

; Note on values this is assuming miliseconds, don't remember if 
; current IDEs of Basic Atom is in Mils or micros...
S1PULSEMAX		con		2250 ; verify with your servos
S1PULSEMIN		con		750
S1PULSEDELTA	con		50   ; change to very smoothness
S1REPEATPERSTEP	con		10		

S1PulseWidth 	var 	word
S1SwingUp 		var 	bit
S1Cnt 			var 	word

	; Initialize everything
	S1SwingUp = 1
	S1PulseWidth = S1PULSEMIN
	S1Cnt = 0
	
	low p13

Main:
	Pulsout p13, s1PulseWidth
	S1Cnt = S1Cnt + 1
	if S1Cnt = S1REPEATPERSTEP then
		s1Cnt = 0
		if S1SwingUp then	
			if s1PulseWidth >= S1PULSEMAX then
				S1PulseWidth = S1PULSEMAX
				S1SwingUP = 0
			else
				S1PulseWidth = S1PulseWidth + S1PULSEDELTA
			endif
		else
			if s1PulseWidth <= S1PULSEMIN then
				S1PulseWidth = S1PULSEMIN
				S1SwingUP = 1
			else
				S1PulseWidth = S1PulseWidth - S1PULSEDELTA
			endif
		endif
	endif
	
	; Could do similar to above for Servo2 with different defines
	; But would add counter that every so many repeats would turn on or off
	; your other IO line	

	
	pause	20	; Probably need to tinker with this value
	goto main

	

Note, I have not tried this out, there are probably things missing, but it might help you get started.

Good Luck
Kurt

Hi Mike,

Yes certainly I will want to learn for long term.

In fact, just order a hex bot for the fun of it… but due to time constraint, I need it up asap. Can’t have the luxe of 1wk to learn and trial & error… I did tried some basic command but seem to have issue connecting to the BB… COM1 recognised the ATOM28… but trying to do the hardware test shows connection error, check connection, power, etc… i also changed the value of Reset Hold Time as recommended by the tutorial but to no avail…

just a wild guess but are you using a USB-to-RS232 serial adapter? if so, in the interest of saving time, do you have access to a computer with a hardware RS232 serial port on it?

In order to help with these types of issues, you need to provide additional information, like which version of the software are you using. What type of serial connection (built-in vs USB to serial adapter), what type of power you have connected to the board, …

Kurt

Hi Kurt,

As you wrote, I found my prgrammer and passed the set to him to settle… But he’s busy this week with mega project with the forces… Very tempted to get it back from him and try out the program you written… Thanks so so much for the initiation!! Really appreciate it…

Eddie, I did try to use the USB-Serial but not successful in detecting the chip in COM9 (the last available on my PC)… So I went out and bought a dedicated RS232 3m cable to try. It did detect the chip which is the Basic Atom 28 on COM1 but just don’t no why it cannot connect… even after I tried loading the test program, and clicked Program, there was no error messages except the programming progress window closed successfully, but the messages at teh bottom still show programming…

The software version is BMIde & MBasic Compilier 5.3.1.3, Device DLL 1.3.1.3.

The board is currently connected to a DC Power Supply (I tried 5.0V to 5.7V) for VS and also a AC-DC 9V PS.

Have you looked over the serial port troubleshooting pages?
lynxmotion.net/viewtopic.php?t=4702

If you got the progress bar and no error message apeared then it programmed successfully. The output window doesn’t get a final message saying it finished programming.