MeArm.Joystick Software En

by ted99tw in Circuits > Robots

21200 Views, 63 Favorites, 0 Comments

MeArm.Joystick Software En

meArm auto mode
meArm manual mode
甲蟲王者機械手臂
2.png
3.jpg
4.jpg
5.jpg
6.png
7.jpg

Origin : Phenoptix's Pocket Sized Robot Arm.

FB , HomePage

DIY manual

- There are 37 programming lessons, good for beginners and veteran. Students from elementary school can use S4A or Ardublock or mBlock. There are also lessons available based on C language. One can learn without programming skill.

- Please go through step A, B and C to install necessary software and driver.

- Please go through step D and E to install drag-and-drop style languages. (S4A or Ardublock)

- You can restore factory default any time by uploading meArm.ino any time in Arduino IDE.

- Feel free to download all of the lessons at a time. (30 lessons.zip , will be available after the end of crowdfunding)

- Restore meArm.Joystick to factory default, please upload meArm_bt.ino(with Bluetooth) or meArm.ino in Arduino IDE.

A) Arduino IDE

B) Necessary driver:

Windows:

Double click Arduino_driver.exe

MAC:

1) double click ch34xInstall.pkg

2) For Yosemite (OSX 10.10), please open terminal and input via the below instruction. Reboot after that.

sudo nvram boot-args="kext-dev-mode=1"

Linux:

Follow the instruction of readme.txt in CH341SER_LINUX.zip

C) Setup Arduino IDE

Windows:

1) System-Device Manager-Ports (CH-340 is is COM3 in this example)

2) Choose "Arduino UNO"

3) Select correct port. (COM3)

4) Select "Arduino as ISP" as programmer

MAC:

1) Application-Tools-System Info (Plug in meArm.Joystick and ensure "USB2.0-Serial" is there)

2) Choose "Arduino UNO"

3) Select "dev/tty.wchusbserial410"

4) Select "Arduino as ISP" as programmer

D) S4A

1) Download and replace S4A.Image at S4A installation folder.

Windows : C:\Program Files\S4A\S4A.Image

MAC : Macintosh HD/Application/S4A/S4A.Image

2) Open Arduino IDE, upload S4AFirmware15_meArm.ino to meArm.Joystick

E) Ardublock

After Arduino installation, please copy "ardublock-beta-20140828.jar" to:

Windows 7 : C:\Users\lienhungcheng\Documents\Arduino\tools\ArduBlockTool\tool\ardublock-beta-20140828.jar

Windows XP : C:\Program Files\Arduino\tools\ArduBlockTool\tool\ardublock-beta-20140828.jar

MAC: /Users/lienhungcheng/Documents/Arduino/tools/ArduBlockTool/tool/ardublock-beta-20140828.jar

(Please replace "lienhungcheng" with your user name.)

F) Manual : meArmJoystick-en.pdf

Turn on the Light.

_1.png
_2.jpg
_3.jpg

We can use C/S4A/Ardublock to control meArm.Joystick.

A) S4A

(1) Open S4A application.

(2) Drag and drop as the blocks.

(3) Click "Green Flag" and the LED on the bot will light up.

B) Ardublock

(1) Select Tools/Ardublock

(2) Drag and drop as the blocks

(3) Press "Upload to Arduino"

C) C

(1) Open _01.ino

(2) Press "Upload"

PS. The pin of LED is 3 (12 in S4A). It will light up if the value is HIGH. You can open ".sb" in S4A, ".abp" in Ardublock or ".ino" in Arduino IDE to get the same result.

Downloads

Turn Off the Light After 3 Seconds

02.png

To turn it off, we only have to set the pin to "LOW" or "OFF" after delaying 3000 milliseconds.

Downloads

Flash It

03.png

Since you are able to turn the LED on and off, why not flash it? Now let's flash it at every 1 second.

Downloads

Variable

04.png

Assuming we are changing the flashing frequency from 1 flash per second to 1 flash per 0.2 seconds, we would have to change the delay time many times. If we use Variable, we only have to change Variable one time to get the job done.

Variable (continue)

05.png

Since we have variable, why not vary it again? Let's try add/minus/multiply/divide
mytime = mytime / 2;

mytime = mytime * 2;

mytime = mytime + 100;

mytime = mytime - 250;

Print Out Variables

06.png

Since variable is so efficient, we should handle that as best as possible. We can use the below instruction to print it out.

If I Am True

07.png

"If" statement is widely used in everyday life. For example, if it rains, bring an umbrella. If it's windy, wear a coat. If the condition is true, we do some kind of action.
"If 10 is greater than 1, turn on the LED."

Since 10 is great than 1, so the LED will light up.

If + Variable

08.png

We normally use Variable with If statement. In this lesson, "light" variable could be a current light value from the sensor.
int light = 5;

if (light < 10)

{

digitalWrite(3, HIGH);

delay(1000);

}

"Boolean" Is a Friend of "If"

09.png

In last lesson, if "(light < 10), we call it "True." If not, we call it "False."

True and False are both Boolean. We do a certain action if the Boolean value is True, and do others if False.

Left Turn or Right Turn (if-else)

10.png

Since there are 2 kinds of Boolean value, the statement usually looks like "if-else."
if (true)

{

left turn

}

else

{

right turn

}

Left Turn or Right Turn (if-else) Continue 1

11.png

"if-else" statement is frequently used with variable.

For instance, "if variable can be divided by 3, then blabla…"
("|" is modular)

if (num | 3 == 0)

{

digitalWrite(3, HIGH);

} else {

digitalWrite(3, LOW);

}

Left Turn or Right Turn (if-else) Continue 2

12.png

Since "if-else" is so important, let's do more practice.
Can you figure out how to write the statement "if odd, flash LED 1 time, else flash 2 times?"

Loop : Capable of Doing Repeated Boring Things

13.png

Besides "if-else", another fantastic work computer can do is "loop." It's capable of doing repeated and boring things.
For example, let's flash LED 5 times.

Basic format in C language : "for (int i = 0; i < 5; i++)"

Use Loop to Add From 1 to 100

14.png

Let's practice how to add from 1 to 100 with loop.

We Can Also Only Add Even Number Within the Loop.

15.png

"Loop" is so powerful. Let's try to add only even numbers within 1 to 100.

"Step" of Loop

16.png

The idea of step of the loop is to do action once per "step" times.

So we can it to add only even number with step 2.

Can We Use "step" to Find Out Total Sundays in a Year?

17.png

The key of this quiz is to set the "step" value.

Loop (continue): Do Something Forever

18.png

Loop statement is so important in most programming language. So there is another variation of this statement "while." The key of the "while" statement is to do forever if the condition is met.

Loop (continue) : Standard Form

19.png

In order not to hang up the system, we usually add a condition in the while loop. So the while loop will stop when the condition is False.

Flash the LED Forever

20.png

The while loop is best to do something unchanged repeatedly. This lesson is to learn how to flash the LED forever.

Function : a Set of Statements in a Blackbox

21.png

To make the code tidy, programmer used to utilize "Function" to run a set of statement as a blackbox. This blackbox is so-called "Function" or "Subroutine." We will learn how to use Function in this lesson.
PS. Only Arduino C and Ardublock support "Function" capability. S4A doesn't.

Function + Loop : Let's Flash the LED 10 Times.

22.png

After wrapping multiple statements into Function, we can treat this special Function as a statement. Hence we can put the Function into a loop as well. Let's see how to flash LED 10 times by using Function and loop.

Loop Inside the Function

23.png

Not only can we run Function within a loop, we can run loop within a Function as well.

Parameter of a Function (Only C Supports, Ardublock Doesn't.)

24.jpg

"Function" is so powerful. For instance, we can provide a parameter when run a Function. In this example, we will pass a parameter to a Function to flash the LED X times.

Can We Pass Multiple Parameter to a Function?

25.jpg

No only can we pass parameter to a Function, we can pass multiple ones as well. For example, we can pass 2 parameters. One is for the times of flash while the other as the frequency.

More Challenging

26.jpg

A Function with parameter is so powerful. So give a try and see if you can work out a Function to add from 1 to number y. So if we want to add from 1 to 100, we can just call "Sum(100)."

Servo at a Glance

27.png

From this lesson, we are going to learn how to control meArm.Joystick. Since you have run through previous lesson, you can get the idea how to control the bot quick.
The mechanic arm is driven by 4 servos. We only have to set the pin number and angle of the servo, and Arduino will do the others for you. The angle is ranged from 1 to 179. Please be careful that you don't turn the servo to an angle out of range. This will harm the system and servo. Please pay special attention that don't drive the screws in too tight. As it will also be harmful to the system if the servo can't turn to a specific angle due to this reason.

Turn the Servo Slowly From 1 to 179 Degree

28.png

Since the range of the servo is 1~179, let's rotate the bot degree by degree.

Let's Try the 2nd Servo With an Angle From 45 to 145 Degree.

29.png

The 2nd servo is to control meArm.Joystick forward and backward. Let's rotate it from a 45 to a 145 degree.

Let's Try the 3rd Servo With Angle From 90 to 179 Degree.

30.png

The 3rd servo is to control the direction of up and down. Let's rotate it from 90 to 179 degree.

Let's Try the 4th Servo With Angle From 0 to 50 Degree.

31.png

The 4th servo is to control the claw. Let's rotate it from 1 to 50 degree.

Read the Value of Joystick

32.png

There are 2 joysticks with 2 directions(left-right, forward-backward) of each joystick. So we need to monitor 4 directions through analog pins A0, A1, A2 and A3. The value of each analog pin is from 0 through 1023. In this lesson, we read value from A0 and print it out through the serial port.

Let's Divide the Value of 0~1023 Into 3 Parts

33.png

The reason is to detect the user operation of the joystick. If the value is greater than 612, it says "bigger," if less than 412 it says "smaller," otherwise says "middle."

Combine Joystick and Servo

34.png

Let's combine the joystick and servo by adding or minusing the servo degree based on joystick direction.

Array : Collect Similar Things Together

35.png

Since we are reading value from 4 joysticks and controling the degrees of 4 servos, we can use Array to store similar values in an "Array" variable. So the code will look tidy.

Combine Everything Together and the Bot Will Be Under Your Control

36.png

To fully control the bot, we need to use all the programming skills we learned from previous lessons. We won't go through each line of code. Try to study the code and you can understand it after short period of time.

Auto Mode

37.png

Since we knew how to control the servo, we can make the bot to automatically do something if we can set the angle of each servo in advance.

Restore the Factory Default

forum-link-building.jpg

You can restore the bot to factory default by uploading meArm.ino in Arduino IDE any time. If you have any problem, please add me as a friend "Lien Ted" in Facebook or email me at ted99.tw@gmail.com. Or join the forum in joyarm.weebly.com.