iPhone as LCD to view/modify PID settings

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
mahowik
Posts: 332
Joined: Sun Apr 10, 2011 6:26 pm

iPhone as LCD to view/modify PID settings

Post by mahowik »

Hi all!

I have connected my iPhone directly to Arduino via RX/TX cable + slightly modified the LCD code part in 1.7 sketch.
In two words it's replacement of the LCD (or serial monitor) and now it's possible to change the PID settings using the iPhone and transmitter in the field without notebook...

Does anyone interesting in details? Or probably someone already done this for MultiWii? :)

Charlienofun
Posts: 4
Joined: Thu Jun 09, 2011 4:25 am

Re: iPhone as LCD to view/modify PID settings

Post by Charlienofun »

is your phone jailbroken? or do you have some serial adapter like from http://redpark.myshopify.com/products/console-cable?

Charlie

mahowik
Posts: 332
Joined: Sun Apr 10, 2011 6:26 pm

Re: iPhone as LCD to view/modify PID settings

Post by mahowik »

Exactly! You should have iPhone with jailbrake.
Firstly I was going to buy some cable BUT didn't want to wait about 3-4 weeks for delivery and I have done cable manually using connector from (unused for me) iPhone dock. It necessary only two pins from iPhone: 13 - RX, 1 - GND
http://pinouts.ru/CellularPhones-A-N/iP ... nout.shtml

iacopo
Posts: 6
Joined: Sun May 15, 2011 11:49 am

Re: iPhone as LCD to view/modify PID settings

Post by iacopo »

I'm very interested in this!!
It would be awesome to use the iphone without the need for an external LCD display!
Please tell us more about the software and how you make it work! :D

toshirotamigi
Posts: 8
Joined: Fri Mar 18, 2011 3:47 pm

Re: iPhone as LCD to view/modify PID settings

Post by toshirotamigi »

Hello,
I'm interested too.
In the meantime i found this:
http://code.google.com/p/btstack/
that is a bluetooth stack that should support SPP on iphone.
I have to investigate further but it seems to be what we need to use iphone with bluetooth module.

mahowik
Posts: 332
Joined: Sun Apr 10, 2011 6:26 pm

Re: iPhone as LCD to view/modify PID settings

Post by mahowik »

Here is some guide how do this:

First of all before the start you should have Jailbroken iPhone or iPod Touch

1. You should buy cable or do this manually. I have used the connector from iPhone dock http://f.imagehost.org/0453/3rd_3G_dock.jpg
See the scheme in attached picture. Also iPhone pin mapping here http://pinouts.ru/CellularPhones-A-N/iP ... nout.shtml
Note: To use your iPhone only as serial monitor (our case) you don't need to connect Arduino RX to iPhone TX (pin12). So it's marked as optional on image.

Image

UUps sorry... Forgot to paint connection between Arduino and iPhone (1st or 2nd pin) GND.

2. Install Minicom, Terminal and OpenSSH from Cydia. Also Toggle SSH or SBSettings to switch on/off the SSH server on your iPhone.

Note: I have not found the Minicom in Cydia and just installed this from command line (using SSH and Putty):
> su
> alpine
> apt-get install minicom

3. Configure the minicom as described in link below
http://www.ohscope.com/2009/02/24/seria ... h-minicom/
Note: I have used serial source 115200 8N1 to be in compatibility with default SERIAL_COM_SPEED specified in MultiWii sketch...

4. Uncomment in sketch:

#define LCD_CONF
#define LCD_TEXTSTAR

Then replace the LCD code with code below (for MultiWii 1.7 version):

Code: Select all

void initLCD() {
  blinkLED(20,30,1);
  #if defined(LCD_TEXTSTAR)
    // Cat's Whisker Technologies 'TextStar' Module CW-LCD-02
    // http://cats-whisker.com/resources/documents/cw-lcd-02_datasheet.pdf
    // Modified by Luca Brizzi aka gtrick90 @ RCG
    LCDprint(0xFE);LCDprint(0x43);LCDprint(0x02); //cursor blink mode
    LCDprint(0x0c); //clear screen
    LCDprintChar("\n\n\n\n        ");
    LCDprintChar("MultiWii: CONFIG PARAMS");
    LCDprintChar("");
    delay(2500);
    LCDprint(0x0c); //clear screen
  #else
    Serial.end();
    //init LCD
    PINMODE_LCD //TX PIN for LCD = Arduino RX PIN (more convenient to connect a servo plug on arduino pro mini)
  #endif
}

void configurationLoop() {
  uint8_t chan,i;
  uint8_t param,paramActive;
  uint8_t val,valActive;
  static char line1[17],line2[17];
  uint8_t LCD=1;
  uint8_t refreshLCD = 1;

  typedef struct {
    char*    paramText;
    uint8_t* var;
    uint8_t  decimal;
    uint8_t  increment;
  } paramStruct;
 
  static paramStruct p[] = {
  {"PITCH&ROLL P", &P8[ROLL],1,1},
  {"ROLL   P", &P8[ROLL],1,1},     {"ROLL   I", &I8[ROLL],3,5},  {"ROLL   D", &D8[ROLL],0,1},
  {"PITCH  P", &P8[PITCH],1,1},    {"PITCH  I", &I8[PITCH],3,5}, {"PITCH  D", &D8[PITCH],0,1},
  {"YAW    P", &P8[YAW],1,1},      {"YAW    I", &I8[YAW],3,5},   {"YAW    D", &D8[YAW],0,1},
  {"LEVEL  P", &PLEVEL8,1,1},      {"LEVEL  I", &ILEVEL8,3,5},
  {"RC RATE", &rcRate8,2,2},       {"RC EXPO", &rcExpo8,2,2},
  {"PITCH&ROLL RATE", &rollPitchRate,2,2}, {"YAW RATE", &yawRate,2,2},
  {"THROTTLE PID", &dynThrPID,2,2},
  };

  initLCD();
  param = 0;
  while (LCD == 1) {
    if (refreshLCD == 1) {
      strcpy(line2,"                ");
      strcpy(line1,"                ");
      i=0; char* point = p[param].paramText; while (*point) line1[i++] = *point++;
      uint16_t unit = *p[param].var;
      if (param == 12) {unit *=2;} // RC RATE can go up to 500
      char c1 = '0'+unit/100; char c2 = '0'+unit/10-(unit/100)*10; char c3 = '0'+unit-(unit/10)*10;
      if (p[param].decimal == 0) {line2[6] = c1;  line2[7] = c2;   line2[8] = c3;}
      if (p[param].decimal == 1) {line2[5] = c1;  line2[6] = c2;   line2[7] = '.'; line2[8] = c3;}
      if (p[param].decimal == 2) {line2[5] = c1;  line2[6] = '.';  line2[7] = c2;  line2[8] = c3;}
      if (p[param].decimal == 3) {line2[4] = '0'; line2[5] = '.';  line2[6] = c1;  line2[7] = c2; line2[8] = c3;}

      #if defined(LCD_TEXTSTAR)
        LCDprint(0x0c); //clear screen
        //LCDprint(0xFE);LCDprint('L');LCDprint(1);
        LCDprintChar("\n\n\n\n        ");
        LCDprintChar(line1); //refresh line 1 of LCD
        //LCDprint(0xFE);LCDprint('L');LCDprint(2);
        LCDprintChar(line2); //refresh line 2 of LCD
      #else
        LCDprint(0xFE);LCDprint(128);LCDprintChar(line1);
        LCDprint(0xFE);LCDprint(192);LCDprintChar(line2);
      #endif
      refreshLCD=0;
    }
    for (chan = ROLL; chan < 4; chan++) rcData[chan] = readRawRC(chan);
    //switch config param with pitch
    if (rcData[PITCH] < MINCHECK && paramActive == 0 && param<16) {
      paramActive = 1;refreshLCD=1;blinkLED(10,20,1);
      param++;
    }
    if (rcData[PITCH] > MAXCHECK && paramActive == 0 && param>0) {
      paramActive = 1;refreshLCD=1;blinkLED(10,20,1);
      param--;
    }
    if (rcData[PITCH] < MAXCHECK && rcData[PITCH] > MINCHECK)  paramActive = 0;
    //+ or - param with low and high roll
    if (rcData[ROLL] < MINCHECK && valActive == 0 && *p[param].var>p[param].increment-1) {
      valActive = 1;refreshLCD=1;blinkLED(10,20,1);
      *p[param].var -= p[param].increment;  //set val -
      if (param == 0) *p[4].var = *p[0].var; //PITCH P
    }
    if (rcData[ROLL] > MAXCHECK && valActive == 0) {
      valActive = 1;refreshLCD=1;blinkLED(10,20,1);
      *p[param].var += p[param].increment;       //set val +
      if (param == 0) *p[4].var = *p[0].var; //PITCH P
    }
    if (rcData[ROLL] < MAXCHECK && rcData[ROLL]  > MINCHECK) valActive = 0;
    if (rcData[YAW]  < MINCHECK && rcData[PITCH] > MAXCHECK) LCD = 0;
  }
  #if defined(LCD_TEXTSTAR)
    blinkLED(20,30,1);
    LCDprint(0x0c); //clear screen
    LCDprintChar("\n\n\n\n        ");
    LCDprintChar("Saving Settings...");
  #endif
  writeParams();
  #if defined(LCD_TEXTSTAR)
    LCDprintChar("..done! Exit.");
  #else
    Serial.begin(SERIAL_COM_SPEED);
  #endif
}


5. Connect the cable from Arduino to iPhone

6. Run terminal

7. type:
> su
> alpine
> minicom

8. See here how to configure PID via LCD http://www.multiwii.com/?page_id=104

9. Enjoy with you new "iPhone LCD"!!!
Attachments
arduino-to-iphone.PNG
(59.47 KiB) Not downloaded yet

raptor30
Posts: 4
Joined: Wed Mar 14, 2012 1:38 pm

Re: iPhone as LCD to view/modify PID settings

Post by raptor30 »

any updates on this project please

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: iPhone as LCD to view/modify PID settings

Post by Hamburger »

You should probably use a terminal program of your choice on the phone and enable vt100 mode in mwii.
I have no experience with shortcomings of iphone, so jailbreak may be neccessary.

mahowik
Posts: 332
Joined: Sun Apr 10, 2011 6:26 pm

Re: iPhone as LCD to view/modify PID settings

Post by mahowik »

Hamburger wrote:You should probably use a terminal program of your choice on the phone and enable vt100 mode in mwii.
I have no experience with shortcomings of iphone, so jailbreak may be neccessary.


exactly! you need jailbreak + vt100 enabled

Eugene_skr
Posts: 42
Joined: Mon May 20, 2013 10:31 pm
Location: Belarus, Minsk

Re: iPhone as LCD to view/modify PID settings

Post by Eugene_skr »

so after two years after this thread started its became possible :) without jailbreak
iphone 4s iphone 5,5s,5c, ipad mini, ipad 3,4 supported
ios 5.1.1 and higher

http://www.multiwii.com/forum/viewtopic.php?f=8&t=3584&p=36419

little demo

Post Reply