Show Posts
Pages: [1]
1  Community / Gigs and Collaborations / Hardware help - Making a MCP Module for Flight Sim on: July 17, 2011, 06:47:54 am
Hello.

Thought I'd drop by as I finally get a little more time, and want to get back to a project I had to do with arduino but for which I need someone's help on the hardware side, as good as I can be in programming, I've really very little knowledge on electronics. Right now I've in my possession since quite sometime an arduino Diecimilla, not the latest one so obviously using the latest model is not a problem. With my little knowledge I thought maybe it would be easier maybe though with the Arduino 2560 because of the much higher number of I/O pins, but I really don't know what is the best.

Okay now what is exactly the project, well I'm quite a simmer, and I always yearned to make a "little" MCP for controling the autopilot within the sim, with something real, anc actually, a 737-800 MCP as source, and I thought of purchasing one, but I saw the price going around 1000€ so well I thought it was probably possible to do something on my own, that would not be that expensive.

I've made a rundown on what is needed so here it is what would composed an MCP.
13 square push buttons with leds
3 small round push buttons
5 rotary selectors (4 rounded, one kind of volume buttons)
1 double rotary selectors
4 simpler switches that flips up/down
3 green leds
6 numerical displays (3 for three numbers, 1 for five numbers and negative sign, 1 for three numbers and decimal symbol, 1 for four numbers and plus/minus symbol)

And that should be about it, the goal in it self is quite simple, I need to be able to get inputs, and make leds, or button leds on and off following user actions, and display values accordingly.

I've done a little trial a while ago and was able to get values to and from the sim and through the arduino creating a little program that would do the talk between both, so I know the transmission of data is possible, though it was very simple and the arduino was just incrementing/decrementing values so I would check if it worked, with no electronics behind.

Well I don't know if it is complex or anything, that's just something I've wished to do for quite sometime, and that I think once done and working to share schematics, program and everything so that it can be used by other on their own and adapted maybe by others for other kidn of aircraft and all.

I don't know the correct eletronic terms for each kind of switches and all, that's why I need a bit of help, even to know if that is possible to do.

Here is the result I want to approach, I know I will probably not get to the exact point of the real thing, but at least approach it and have the complete functionality, which is the most important.

Have a look at this picture which represent what it looks like : http://www.facebook.com/photo.php?fbid=209922335714225&set=pu.165758250130634&type=1&theater

Cheers.

Aurelien


2  Forum 2005-2010 (read only) / Interfacing / Re: Interfacing with C/C++ under windows on: December 20, 2008, 06:42:33 am
Hello.

I just finally put the wiki page so the code is now available for those who need it at : http://www.arduino.cc/playground/Interfacing/CPPWindows
3  Forum 2005-2010 (read only) / Interfacing / Re: Interfacing with C/C++ under windows on: December 07, 2008, 04:26:44 am
I just sent you the code by MP, I'll keep checking stuffs and will put it on the playground ion a few days smiley

as for the reset I was thinking that some kind of very specific code or succession of bytes was sent through the Serial comm in order to ask for the reset smiley but well now that I know that it makes sense that I had troubles smiley-wink
4  Forum 2005-2010 (read only) / Interfacing / Re: Interfacing with C/C++ under windows on: December 04, 2008, 01:07:02 pm
Hello everyone,

And first thing thirst, thanks for the great help you gave to me smiley I finally got my arduino and PC exchange things through Serial connection on Windows. Using the standard windows library. I'll continue tweak things a little, and once I'm satisfy I'll add the final code of my Serial Class and a little tutorial on how to make it work so that it can be used by anyone, or even be improved by others smiley

So I understood that the problem was that once you connect to the Arduino board it resets itself and need a little time before being ready, that is I would say the key I was missing, because I never thought the Arduino could reset itself at any Serial connection made to the board, and actually it is a little unexpected, I thought only the update of a new sketch, pushing the reset button, or of course turn the power on/off, were the only case where the board would restart it self.

Well now I'll be working on my code and program, and first thing first define the way the board will exchange data with my program, but now that is not a very hard problem, and not at all a Serial Programming trouble smiley-wink

So once again, I want to thank you all for your support.

Aurelien
5  Forum 2005-2010 (read only) / Interfacing / Re: Interfacing with C/C++ under windows on: December 03, 2008, 01:23:27 pm
Hello.

Thanks for your help, I know can read asynchronously which is really great, I'm really new to the serial programming side. So as I said yes the Write don't work, and what's weird is that I see the RX led lights when I send something with the WriteFile function, only Arduino do not react, or well do not receive correct info, because when I send the same thing with the Serial monitor include with the arduino programming tool. So it should just work the same.

So here are the two important bits of code :

First what my arduino board do
Code:
int ledPin = 13;                // LED connected to digital pin 13
int incomingByte;

boolean connected = false;

void setup()                    // run once, when the sketch starts
{
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
  Serial.begin(9600);
}



void loop()                     // run over and over again
{
  if(connected)
  {
    digitalWrite(ledPin, HIGH);   // sets the LED on
  }
  
  if(Serial.available() > 0)
  {
    incomingByte = Serial.read();
    
    Serial.print("I received: ");
    Serial.println(char(incomingByte));
    
    connected = true;


  }
  
}

Nothing too fancy here I just resend what I received, and lights the led so there is a visible status on the board.

and here is the class I'm using for Serial :
Code:
Serial::Serial(char *portName)
{
    this->connected = false;

    this->hSerial = CreateFile(portName,
            GENERIC_READ | GENERIC_WRITE,
            0,
            NULL,
            OPEN_EXISTING,
            FILE_ATTRIBUTE_NORMAL,
            NULL);

    ::memset(&this->ovr, 0, sizeof(this->ovr));

    this->ovr.Offset = FILE_WRITE_TO_END_OF_FILE;
    this->ovr.OffsetHigh = -1;

    if(this->hSerial==INVALID_HANDLE_VALUE)
    {

        if(GetLastError()==ERROR_FILE_NOT_FOUND){

            //Print Error if neccessary
            printf("ERROR: Handle was not attached. Reason: %s not available.\n", portName);

        }
        else
        {
            printf("ERROR!!!");
        }
    }
    else
    {
        DCB dcbSerialParams = {0};
        if (!GetCommState(this->hSerial, &dcbSerialParams))
        {
            printf("failed!");
        }
        dcbSerialParams.BaudRate=CBR_9600;
        dcbSerialParams.ByteSize=8;
        dcbSerialParams.StopBits=ONESTOPBIT;
        dcbSerialParams.Parity=NOPARITY;

         if(!SetCommState(hSerial, &dcbSerialParams))
         {
            printf("\n\nALERT: Serial port failed!");
         }
         else
         {
             this->connected = true;
         }

    }

}

Serial::~Serial()
{
    if(this->connected)
    {
        this->connected = false;
        CloseHandle(this->hSerial);
    }
}

bool Serial::ReadData(char *buffer, int nbChar)
{
    char szBuff[100];
    DWORD bytesRead;
    COMSTAT status;
    DWORD errors;

    ClearCommError(
    this->hSerial,      // handle to communications device
    &errors,   // pointer to variable to receive error codes
    &status);

    if(status.cbInQue>0)
    {
        ReadFile(this->hSerial, szBuff, 1, &bytesRead, NULL);
        //printf("%d\n", (int)bytesRead);
        if(bytesRead != 0)
        {
          printf("%c", szBuff[0]);
        }
        return true;
    }

    return false;

}

bool Serial::WriteData(char *buffer, int nbChar)
{
    DWORD tmp;
    COMSTAT status;
    DWORD errors;

    //WriteFile(this->hSerial, buffer, nbChar, &tmp, NULL);
    if(!WriteFile(this->hSerial, (void *)buffer, nbChar,
                 &tmp, 0))
    {

        ClearCommError(
        this->hSerial,      // handle to communications device
        &errors,   // pointer to variable to receive error codes
        &status);

        printf("%d\n",(int)errors);

        return false;
    }
    else
        return true;
}

bool Serial::IsConnected()
{
    return this->connected;
}

And the line I have set once connected in the main program :
Code:
serial->WriteData("HELLO", 5);
6  Forum 2005-2010 (read only) / Interfacing / Re: Interfacing with C/C++ under windows on: December 02, 2008, 02:33:02 pm
Thanks for your answers.

I've had a try with the CreateFile and that is working at least partly, I manage to read stuff, but write don't seem to work, which is the first problem, and the other is that the Read wait for data to be available, so you can't use it except when you're sure there is data else it'll just freeze the program till something arrives.

I've nothing agains Microsoft, and I've found the VB solution with and RS232 stuff that is perfectly working, but as I said initialy, I really require to use C/C++ because of the library I need to use. As far as I know I can't link a C written library in a VB program although that would be nice smiley

I'll check the Borland Compiler, don't know it, but if I can get the library I need to use working with it, and find the stuff I need in their Serial lib, it might do the trick. Well I'll need to put also gtk which I use for interface working with it. but I'll gave it a try.
7  Forum 2005-2010 (read only) / Interfacing / Re: Interfacing with C/C++ under windows on: December 01, 2008, 02:24:48 pm
Hello.

Thanks for this link which I had missed, but I'm more searching for something more opened, or at least free, I'm not really ready to put more than a hundred of $ to purchase a library. And my aim is to provide when finished everything on both the playground and to many peoples.

Aurelien
8  Forum 2005-2010 (read only) / Interfacing / Interfacing with C/C++ under windows on: November 25, 2008, 02:46:07 pm
Hello.

I need a little help on that matter that for some reason I just can't seem to find any code, or library for Serial communication under Windows and C/C++. I found loads of sample, like using VB, C#, or even C/C++ under linux but nothing for Windows (yet).

Some might say I should just switch to another language but I would be stuck because one of the library I need to use is only really updated and developed in C, and that othere have less support. Of course there is always the option to develop a bit on C++ with that library, the other in another language which I can use Serial with, and interconnect the two by some network connection or things like that, but that would not be very interesting and would require two programs to be run at a single time.

I hope someone have a tip or some docs on this matter. I'm using Code::Blocks and the MinGW compiler for several reasons, but in the worst case I could switch if necessary to Express version of VS C++.

Thanks

Aurelien

9  Forum 2005-2010 (read only) / Français / Re: Arduino et Communication avec PC on: December 09, 2008, 11:43:02 am
Salut,

J'ai pas regardé en détail mais je dirai que oui en théorie. Il y a une page dédiée au sujet sur le playground : http://www.arduino.cc/playground/Interfacing/Flash
10  Forum 2005-2010 (read only) / Français / Re: Arduino et Communication avec PC on: December 08, 2008, 01:02:25 pm
Salut,

Bon j'ai finis par résoudre le soucis en développant ma propre classe C++ utilisant la librairie Windows, qui marche pas mal, je vais encore jouer un peu avec histoire de tout vérifier, et pour ceux que ca intéresse elle sera une fois que j'aurai bien validé son fonctionnement sur le playground smiley-wink
11  Forum 2005-2010 (read only) / Français / Re: Arduino et Communication avec PC on: November 19, 2008, 03:41:13 pm
Salut, si le problème se pose je verrai bien mais apparement j'ai trouvé une classe windows qui a l'air fonctionnelle. Je viens de recevoir mon Arduino Duemillanove et un kit de composant donc je vais pouvoir commencer à regarder ça tranquillement ce Week End smiley
12  Forum 2005-2010 (read only) / Français / Re: Arduino et Communication avec PC on: October 29, 2008, 01:19:07 pm
D'une manière aussi légale les versions Express marche très bien pour un usage perso est sont gratuites smiley-wink

Seulement c'est surtout que je suis habitué au C et que c'est d'un plus grand interêt pour moi, la bibliothèque FSUIPC étant écrite en C à la base même si une lib VB existe, et ca me permet de faire joujou en même temps avec la lib gtk smiley
13  Forum 2005-2010 (read only) / Français / Re: Arduino et Communication avec PC on: October 25, 2008, 03:24:33 am
Salut.

Merci pour toutes vos réponses.

Concernant la vidéo c'est un peu le but avec des différences car je suis en C++ et j'utilise Codeblocks avec le compilateur mingw32 pour des raisons de gratuité et de portabilité. Donc je suis pas trop sûr d'avoir accès au lib Comms de Microsoft.

Mais sinon c'est ca en gros mon principe c'est à l'initialisation d'envoyer une valeur à l'arduino, qui pourra être modifiée via un bouton rotatif, et sera récupéré par le PC ensuite avec une vérification régulière, genre quelques fois par secondes.

Aurélien
14  Forum 2005-2010 (read only) / Français / Re: Arduino et Communication avec PC on: October 21, 2008, 09:56:34 am
Salut.

En effet il s'agit pas d'implémenter des librairies windows sur l'arduino.

Le principe que je souhaite mettre en oeuvre et que mon programme écrit en C/C++ dialogue et échange des informations avec la carte arduino.

Donc si j'ai bien compris évidement c'est à moi de mettre ca en place aussi bien dans mon code que dans celui qui sera sur la carte Arduino, pour concevoir un protocole si je puis dire qui servira à définir comment les données seront échangées.

Il me faut donc chercher du côté des librairies RS232, j'avais plutôt chercher de manière globale des librairies concernant l'USB sans grand succès, donc que la puce soit connecté en USB ne pose pas de problème vis à vis de l'utilisation de librairie lié au port série côté windows ? enfin si j'ai bien compris :p Dans ce cas plus qu'a chercher une librairie correcte à ce sujet smiley
15  Forum 2005-2010 (read only) / Français / Arduino et Communication avec PC on: October 20, 2008, 08:18:10 am
Salut à tous.

Voila j'ai découvert il y a peu Arduino par un ami qui m'a donné quelques idées mais pour cela j'ai quand même au moins une première grosse interrogation.

Mon but est de faire interagir un programme à la suite "d'entrées" sur Arduino. En gros disons un bouton appuyer. J'ai bien vu qu'il y avait des fonctions dans la classe Serial, liées au transfert de message.

Maintenant après un certain temps de recherche je n'ai pas réussi à trouver pour l'instant d'exemple concret et utilisant le C ou le C++ comme langage côté machine, et plus particulièrement sous Windows. Puisque c'est un programme perso que j'aurai besoin de faire fonctionner et dont certaines librairies sont spécifique a un logiciel Windows.

Voila donc si quelqu'un avait ne serait-ce qu'un bout de code ou de tutoriel, voir des informations sur une librairie permettant la communication avec Arduino, voir plus globalement avec un matériel USB en C/C++, ça m'aiderai pas mal afin d'étudier la chose avant de me lancer dans les achats.

Merci

Aurélien
Pages: [1]