Entries in ‘電子工作’

Sorry, this entry is only available in 日本語.

Sorry, this entry is only available in 日本語.

Sorry, this entry is only available in 日本語.

Followings are the tips I got using Xamarin.Forms for several days.

1. Can’t build automatically with F5

The project runs immediately with F5 so I did build & deploy manually in each debug. But I found the checkbox of [Configuration Manager]-UWP project build and deploy, Is it off as default?

2. I got exception in Release mode

I get System.PlatformNotSupportedException: ‘Arg_PlatformNotSupported’ exception when I run Shared Project MainPage. No exception in Debug mode. When I skip this exception, the app runs well. What is it?

3. Xaml intellisense dead

The worst trouble is this. It works some time but after doing something, intellisense will be dead. In UWP context, I haven’t seen intellisense works correctly. I get error like “ContentPage was not found” and have very little choice of code. In Android/iOS context, it works some time but after some operations, intellisense window does not show. In that situation, after removing shared project reference from Android/iOS project and add them again, iintellisense comes again… or not?

The plan of running Weather Typing on Raspberry Pi. I ported logic so I’m making screens.

This is an image 2 weeks ago. With mobile battery, I can take it to anywhere.

This is current image. I can type words with keyboard.

I have platform dependent implementation like keyboard but if I implemented that, the same application will work on Windows 10 IoT on Raspberry Pi, Windows Store (UWP), Android, There seems to be iOS.Xamarin Mac so can it work on Mac?

I can implement battle feature with at least Windows store. In Android, maybe I can implement guest
feature.

And I can use Raspberry Pi feature so I tried hardware. When I press a key on keyboard, LED will be ON/OFF.

Achieving this, I can start that project I wanted to do. I will report here later.

Today is the day of the 2nd Raspberry Pi workshop. We found nice work space in the near field so we
exchanged information. We discussed how to develop Windows 10 IoT app on Mac. We assumed after installing Windows 10 IoT with a PC, we can develop Xamarin app with Visual Studio. And we bought SD card.

It’s about time to buy mobile battery so I bought Maxell mobile battery. It supports 3A so can handle Raspberry Pi.

This is current raspberry pi with mobile battery.

The current goal is running Weather Typing on Raspberry Pi but I wan’t to run it on mobile at the same time so I tried Xamarin.Forms I was interested in.

When I created a cross-platform project in Visual Studio 2017, I got Shared Project and UWP/Android/iOS projects. I can test on UWP before testing on Windows 10 IoT, that is convenient.

There are many way to achieve cross platform development. At first, I can use Portable Class Library (PCL) as is. I can port WPF common project to Shared Project and use ifdef for each platform. The better way may be making interface in PCL and using Dependency Injection but I have too many classes.

Shared Project is not a DLL not a static library. That project will be merged to each platform project. I thought the define value should be defined for each platform but that was not true. I defined platform dependent value such as _UWP__.

How about XAML cross platform? In some books. I can choose using Xamarin Forms or I can make
each platform screen. I wan’t to try Xamarin Forms! But… I think making each platform screen is easier. I don’t see screen image in develop phase, that is okay. But intellisense will be dead when I wrote wrong code. And do I have to Build & Deploy manually before debug code? I think it will be fine after I got some tips, right?

I concerned about GPIO. Does it work with Xamarin? Yes, I can add reference GPIO library from UWP project. Is it normal UWP app instead of Xamarin emulated .NET framework?

This is the first app with UWP on Xamarin.Forms.

I’m trying to run Weather Typing on Raspberry Pi. I can use C# in Windows 10 IoT so started experiment.

As in MS page, copied image from Windows 10 IoT Core Dashboard to SD and run, but it stacks then ended up with BSOD (BAD SYSTEM CONFIG INFO). After that, I get BCD error and the end. I tried it several times
but no luck. After Googling, I get some information of power issue but I can’t use it with Surface charger.

Another topic, After installing Windows IoT, that makes many partitions. I don’t know which partition I have to delete so I deleted all the partition. But after that, Windows lost the SD card. That SD card was recognized after formatted it in Xperia.

After all, that was SD card issue. I can’t use TOSHIBA 16GB and can use ELECOM 16GB.

→That was because my TOSHIBA SD card was class 4. I bought it in convenience store. I bought ELECOM one in electric store so that was class 10.

As official 7 inch touch screen is shown up-side down so I launched Windows 10 IoT Core Dashboard to fix it. But I can’t use the first password I specified. But I got error. it seems the first password
was fixed to “p@ssw0rd”? I changed the password and finally I reversed display direction/

Next, I searched the way to remote control Windows IoT and found Windows Store App. I can remote login with a href=”https://www.microsoft.com/en-us/store/p/windows-iot-remote-client/9nblggh5mnxz?SilentAuth=1&wa=wsignin1.0″>Windows IoT Remote Client. I can start
develop Windows IoT app.

I have almost finished WT3.2 so I’m building Raspberry Pi environment. I attached a touch LCD and case I bought in Akihabara.

I can provide power from Raspberry Pi to LCD, I can easily take it to anywhere. More than anything, I
can remove the back cover. I love it.

Now start Weather Typing on Raspberry Pi project.

I went to Akihabara with Happa for the first time in a while. The goal this time was BEEP秋葉原店 which was on my mind for several month. Basic Magazine like paint was on road and when we entered the shop, there were many retro PC, game, books. There were MSX, x68, even Tiny-Xevious of PC 6001, and many NES games. However, I don’t have items to buy because I can’t play with them because of environment. There were Basic Magazines but I can read them in National Diet Library. Are really core people have gaming environment in their home?

The another goal was Raspberry Pi. I bought camera module I didn’t have one for Arduino. I will try it.

I bought Raspberry Pi a while ago so I played with it.

Raspberry Pi is a small computer and can be used with an OS in SD card. It has I/O pins which I can attach electric parts. In fact, I wanted to install a Wi-Fi and a camera into Arduino and grade up RC. But I can’t install other parts after installed two motors and Bluetooth so I will try Raspberry Pi which has Wi-Fi and camera I/F.

I bought Raspberry Pi and SD card, connect it to HDMI display, connected USB mouse and keyboard. I installed Raspbian (Default Linux) to SD card using PC, then ready. Launching Raspberry Pi and installed OS. After changing password, configured Wi-Fi, finally I was able to login to it with SSH from PC.

I have a problem here. When I use it, IP address will be changed because of DHCP and it is hard to use. I don’t want to connect display and execute ifconfig. Because of that, I created a first program that notify IP address to web site when launched. It was my first Python program so I don’t know details.

# coding: utf-8
import urllib2
import subprocess

url = 'http://xxxxx/cgi-bin/xxxxx.cgi?ip='
cmd = "hostname -I"
ip = subprocess.check_output(cmd,shell=True)
urllib2.urlopen(url + ip)

When Raspberry Pi launched, it seems that pi user automatically logins, so I added following code in .bashrc.

python /home/pi/xxx.py &

In Web side, I created CGI but I can’t copy & paste here because it is link to large original library. It saves given IP address and output latest IP address to standard output.

Now I don’t need display, mouse and keyboard. Super convenient.

I went to Maker Faire Tokyo 2016 with Happa.

It was our first time to join it so we went the 2nd day PM to avoid crowdedness. Not so crowded and not so hot. We skipped event and saw almost all the exhibition. It was so huge and tired. My image was comiket that circles or individuals sell something. Actually, there are university labs, it was like the university festival? So professional.

In electrics, I knew only Arduino,Rapsbery Pi,IchigojJam, but there are many types, extensions, and other frameworks and digital blocks. VR all over the place. Other than electrics, Pitagora devices, keyboard shooter were interesting.

This time, I went there to just a take a look at it, but I got much motivation to make something there.

Now I’m reading “Make: Electronics” and in this book, the author says that you can’t cross wires on both surfaces because they will short through hole. I got it. My shield which I made in previous article has the problem. Actually the wires are not attached to board but it is not good.

In the normal books say “do so.” So they say just use wrapper wires to cross the wires so I thought put wires on both surfaces. This book writes about “do not” so it is good to read.

I monitored the view of RC.

The video output is sent from an iPod Touch on Arduino RC via Wi-Fi. And Windows 10 Mobile show the video real time. RC is also controlled by Windows 10 Mobile via Bluetooth.

I finished RC part so next I will move RC automatically by the video.

In the previous diary, I have made a rc car. But I controlled it in a Windows PC. I think controlling in a smart phone is much smarter so I was planning to make Android App. But wait a minute, I have Windows 10 Mobile so that I can make UWP app on Windows and I can run it on mobile.

In Windows, I was able to use SPP and connect to Bluetooth device by COM port serial. But I don’t see COM port number on my phone… I found that I can’t use SPP on Windows 10 Mobile. OK. I referred to here and change it to use RFCOMM. I only have to change serial connection to socket.

Here is the latest screenshot. I can debug it in Windows as well so it is very easy to develop Windows 10 Mobile app.

201606192159

201606192159

With new soldering iron, I have finished making Arduino RC shield.

Following is the design of the shield. It is hard to understand but Drv1 and Drv2 are motor drivers and U5 and U6 are Bluetooth module RN42 converted by XBEE and 2.54mm pitch board. It was my first time to make circuit board so I remake it several times. Even I thought it was perfect, there was a bug that something like parts collide with each other.

2016052901

Note: The circuit includes important problem so refer to the later article.

This is the component side of the shield. Wires of motors and battery can be attached to pin sockets. I attached jumper wire pins to wires and used heat shrinkable tube.

2016052902

This is the solder side of the shield. Even with new soldering iron, this is the limit. I have to practice more. It may be common to use coating wires to cross the wire but I avoided that by put the wire via component side or using register which is on component side.

2016052903

This is RC. In previous work, the parts on head side and tail side are conflicting so there was a limit how to place parts. This time I used two universal place so that I can use bolt anywhere and put parts freely. In the picture, the metal bar is for putting iPod Touch to record movie.

2016052904

This is the head side.
2016052905

This is the tail side.
2016052906

Arduino。I implemented motor and Bluetooth in breadboard in previous work, so this time, I tried to implement them on Shield. After designing , I soldered some of wires. But socket melted and soldering iron get oxidized. In web searching, I found how to select soldering iron in WEBはんだ付け講座. I used Good’s beginner set but the site says beginner has to buy good one so I bought Hakko. It is easier to use than old one. When I used the old one, it caused damage to land but the new one is OK.

I used distance measure module GP2Y0A21YK and servo SG92R and universal arm which I bought in Akihabara and upgraded my RC. I attached distance measure module on servo and turn those modules. And I made a space for iPod. I will send left and right distance information by Bluetooth and send images of iPod by Wi-Fi to PC and then PC will calculate motion of car. I’m referring a book Arduinoでロボット工作をたのしもう and finished Part1 + alpha.

Happa and I held Arduino workshop in Akihabara. In previous workshop, we shared the challenge that it is difficult to have a workshop without good work space because our work is achieved to this level. After that, I found はんだづけカフェ at Basic Magazine Event and we talked we should go sometime. はんだづけカフェ is a free electronics work space in which we can soldering. We went there at first but it was too crowded because it is a free space.

I expected that so I had plan B. Next, we went Assemblage. It is not free but we were able to work relaxed.

I show Happa my handmaid RC and saw Happa’s Arduino shield creation.Then I soldered distance sensor module I bought in 秋月電子. It was comfortable. My next target is to make my RC detect the collision with this module.

I made radio control car with Arduino.

In previous diary, I made car with double gear box but the car can’t curve smoothly because the front tires are not separated. This time I used Ball Caster to move right and left.

And I used Bluetooth module RN-42 to operate with PC.

It looks like this.

2015051701

2015051702

The system is:

About RN42, I bought XBee 2mm pitch type, so I converted it to 2.54 mm pitch. Akiduki board has 3.3V regulator so I can use Arduino 5V power but I have to use 3.3V to the serial connection from Arduino to RN42 so I used some register to let the voltage down. I used to solder a little but 2mm is hard to solder.

2015051704

I looked web to see how to use RN42. I think using Mac console is the easiest so I connect from Mac. When I connect RN42 and power, the red LED blinks then I can found bluetooth device on Mac. After pairing, red LED will light then I input “screen /dev/tty.RNBT-DF42-RNI-SPP 115200”. I can control the car with keyboard!

Circuit. I used Fritzingto draw it.

2015051705

Program. The hardware is the main part so software is not beautiful but I upload here.

int rpositive = 9;
int rnegative = 6;
int lpositive = 11;
int lnegative = 3;
int led = 13;
int lspeed = 0;
int rspeed = 0;
char inByte = 0;

void setup()
{
  Serial.begin(115200);
  pinMode(lpositive, OUTPUT);
  pinMode(lnegative, OUTPUT);
  pinMode(rpositive, OUTPUT);
  pinMode(rnegative, OUTPUT);
  pinMode(led, OUTPUT);

  analogWrite(lpositive, 0);
  analogWrite(lnegative, 0);
  analogWrite(rpositive, 0);
  analogWrite(rnegative, 0);
}

void loop()
{
  if (Serial.available() > 0)
  {
    inByte = Serial.read();
    if (inByte == 'w')
    {
      // forward
      lspeed += 50;
      rspeed += 50;
      Serial.println('f'); 
    }
    else if (inByte == 's')
    {
      // backward
      lspeed -= 50;
      rspeed -= 50;
      Serial.println('b'); 
    }
    else if (inByte == 'a')
    {
      // left
      lspeed += 50;
      rspeed -= 50;
      Serial.println('l'); 
    }
    else if (inByte == 'd')
    {
      // right
      lspeed -= 50;
      rspeed += 50;
      Serial.println('r'); 
    }
    else if (inByte == 'z')
    {
      // stop
      lspeed = 0;
      rspeed = 0;
      Serial.println('s'); 
    }

    if(lspeed > 200)
    {
      lspeed = 200;
    }
    if(rspeed > 200)
    {
      rspeed = 200;
    }
    if(lspeed < -200)
    {
      lspeed = -200;
    }
    if(lspeed < -200)
    {
      lspeed = -200;
    }

    if(lspeed >= 0)
    {
      analogWrite(lpositive, lspeed);
      analogWrite(lnegative, 0);
    }
    else
    {
      analogWrite(lpositive, 0);
      analogWrite(lnegative, -lspeed);
    }
    if(rspeed >= 0)
    {
      analogWrite(rpositive, rspeed);
      analogWrite(rnegative, 0);
    }
    else
    {
      analogWrite(rpositive, 0);
      analogWrite(rnegative, -rspeed);
    }
    
    if(lspeed != 0 || rspeed != 0)
    {
      digitalWrite(led, HIGH);
    }
    else
    {
      digitalWrite(led, LOW);
    }

    delay(100);
  }
}

Next, I will use smart phone to connect bluetooth.

I tried to move a car with parts I bought yesterday. I connected Tamiya Double gear box, Motor driver TA7291P x2 with 1.5V battery x4. And I used 9V battery to use as the power of Arduino. So far, I can change the direction of the car and it’s USB-cable free.

I bought Tank previous time but at last, I used Tamiya universal board and TIres. I can implement parts to both side of the board.

2015051101

2015051102

Happa and I held Arduino workshop 3 in Akihabara. We bought bluetooth and motor parts.

During the workshop, Happa found IchigoJam and bought one. It’s a board which can connect to TV and execute BASIC program. As we used to post program to Basic Magazine, we can’t miss it. As we were looking the manual of IchigoJam, we read the denshi kosaku magazine has Basic Magazine corner and also bought one. It’s only 2 pages but it surely revived and wanted reader’s program. That’s a good thing.

I tried motor control with Tamiya Tank handcraft basic kit I bought yesterday. I connected motor control IC TA7291SG to Tank motor. I can’t connect Arduino power to motor because Arduino will be corrupted so I need another power for motor. According to some web pages, 3V battery doesn’t work because the current will be low so I used AC adapter – USB. I bought Breadboard mini B USB connector DIP kit so I did solder for the first time. It is not lead recently.

2015041301

Well, I confirmed the output was 5V so it work well.

I connected Arduino power to motor control IC and PWM to control input and then make program. You can see movie.

It is a little slow but it moves forward and backward. Next time, I want two motor to turn left and right or make smartphone controller with bluetooth.

I studied about Arduino with Happa for the second time. In the previous time, we experimented LED and today, the motor is the theme. It would be fun to make something move.

The purpose was to go to Akihabara to see some electronic parts but because of Yamanote line trouble, we went off at Shimbashi. We went to Tamiya Plamodel Factory. There are mini 4wd I played with them over 20 years ago and handicraft kit and plamodel. I never be bored.

After that, We went to Akihabara and went to some parts shops which is Happa’s favorite. We bought motor-related parts. We can’t buy Bluetooth module because time was up.

I want to use Arduino I bought before so I experimented blinking LED with Happa who has experience of electronic circuit. I took part in his lecture and understand basics so I want to do more practical thing next time.

2015011101

2015011102

Today, with a red and green LED and tact switches, we used one switch to make red brighter gradually and another to make green brighter gradually to light up red green yellow. That was fan even just one LED. By the way Happa was doing hardware more than 10 years ago so he doesn’t have blue LED.

I presented Arduino UNO which I bought in America to happa. If I buy it only for myself, I can’t continue to play with it. Arduino is a microcomputer and it is applicable to various purpose with some hardware and software. As I have only Arduino itself, I have to some some hardware.