Solved

C code to read TTL levels

Posted on 2004-04-06
8
228 Views
Last Modified: 2010-04-01
Without going into too much unnecessary information here is my problem.  I have a circuit on a helicopter that i am trying hack into for an electronics project.  Specifically one PIC that i am interested in deals with the command signals to the motors, and i need to read this data to evaluate and decode.  A good way of doing this, or so i'm told, is to simply connect the PIC to a serial input and read the TTL levels, (which are 0V - 5V).  I need a program that will read these levels and convert them to a useable format (1's and 0's) and have been trying to find something on the web, can anyone help?
0
Comment
Question by:Stupot
  • 2
  • 2
  • 2
  • +1
8 Comments
 
LVL 16

Expert Comment

by:George Tokas
ID: 10765470
PIC is a microcontroler.
That means there is a software inside it to perform some actions.
If you take my advice as electronic engineer also, don't try to hack it.
If it is not protected (I mean at programming phase) then you can get the code from inside the PIC and with dissasembly you can see the program and modify it yourself.

Regards,
gtokas.
0
 

Author Comment

by:Stupot
ID: 10765659
That would be ideal, but unfortunately the helicopter is fairly revolutionary in its design and the manufacturers have gone to some lengths to ensure that it cannot be reverse engineered that easily (Like scratching off part numbers e.t.c).  Also it's quite expensive (and not mine), so i can't really take the PIC off the circuit to access the code inside.  Also it's probably been protected, though i haven't checked, but the company are reluctant to give any information regarding the circuitry.
0
 
LVL 44

Assisted Solution

by:Karl Heinz Kremer
Karl Heinz Kremer earned 75 total points
ID: 10767106
The serial port does not use 0/5V signal levels, so you would not be able to use it directly. A better choice is the parallel port, it uses the same signal level as your device.
What operating system are we talking about?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Stupot
ID: 10774994
I will probably use windows, but have the option to use linux if preferrable.
Also, the person who mentioned the idea suggested using the C functions 'inport' and 'outport'.
0
 

Accepted Solution

by:
Jay_Harbath earned 150 total points
ID: 10777834
The hardware way to do this is to use a logic analyzer that clips onto the PIC package and monitors and records all the PIC I/O   Unfortunately that will result in a huge data log of square waves.  You then have to figure out enough of the schematic to understand which control outputs from the PIC are going to the motor control circuitry and which inputs to the PIC come from motor feedback circuitry.  Once you know which pin does what, then you get the exhaustive and exhausting process of trying to determine what algorithm the PIC programmer used to read the inputs and control the outputs.  A nasty, dirty, mind numbing job to say the least.  

The software way would be to remove the PIC from the board, put it into a PIC programmer and attempt to read out the hexadecimal machine code.  This assumes that that particular chip does not have some sort of program security feature that prevents someone (like you) from reading out the program after the chip has been programmed.  Many microcontroller manufacturers have hardware program protection features that can be set after a chip has been programmed and verified.  I use them all the time.  Now, given that the company programming the PIC did not use any sort of program protection, all you will get is a hex file of the contents of the program memory.  You then need a disassembler that can convert the machine code into very, very raw assembly language.  You still need to understand the schematic with this approach, because you will have to understand which control outputs from the PIC are going to the motor control circuitry and which inputs to the PIC come from motor feedback circuitry.  With this information, you can start trying to understand the raw assembly language program and start guessing at variable names for memory locations and I/O pin assignments.  After extremely long hours (days, months) of effort, you might come up with some semblance of a commented assembly language program with a glimmering of the algorithm the original engineer used.  Mind you, this will only be an assembly language equivalent.  It is very likely that the engineer programmed most if not all of the application in C, but no disassembler in the world can go from machine code to C.  Considering how C compilers optimize, you won’t even find one that can convert assembly language back into C.  

To do what it sounds like you want to do will take thousands of dollars of equipment (logic analyzers or PIC programmers) and months of very hard work and lots of knowledge of electronics.  Reverse engineering embedded control applications takes courage, perseverance, and stupidity to make the attempt, strong motivation and very, very deep pockets.  
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 10778579
If you are willing to use Linux, take a look at this project: http://vodka.tky.hut.fi/~jap/Programming/Slogan/
This is a simple logic analyzer that reads eight input channels (the eight data lines of the parallel port). You don't need any special hardware, just the software and the connector.
0
 
LVL 16

Assisted Solution

by:George Tokas
George Tokas earned 75 total points
ID: 10783353
Jay_Harbath put it the right way.
Even if you read the PIC using a programmer if it is protected then the data you will have will be garbage.
For me i.e. if I needed to I will take a look at the circuitry to have an idea of how it is implemented and then I will make a new one of my own.
Anyway the control data from remote controls have a standard protocol.
Jay_Harbath you must be on the same field with me.
Check out my details and contact me if you like.
Regards,
gtokas.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

937 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

4 Experts available now in Live!

Get 1:1 Help Now