Jump to content

[Hardware, Plugin] Arduino based physical display + serial port io+ tutorial (24-11-19)


zitronen

Recommended Posts

I'm tempted to canibalize my Uno IR relay to try this out but I'd be losing a lot of work when I've got something similar done already in a terminal with kRPC in python. Which on that note, I found this which might help someone out especially if you're also a pyfan. It almost sounds like it was done by someone in this thread, anyone know?. Pretty cool resource: www.instructables.com/id/Interface-Python-and-Arduino-with-pySerial/

Link to comment
Share on other sites

Why are you typecasting to long? VData.AP is in float so why not leave it this way? If you want to have more control upon the number of decimal places in float try this:

lcd.print(VData.Ap,2);

where 2 is number of decimal places. If you want none, use:

lcd.print(VData.Ap,0);

Also, if you wish I can send you my function I use to format altitudes with proper handling of meters, kilometers, megameters etc. It displays a value and a unit.

Link to comment
Share on other sites

This are my first steps with arduino. I´m using google and this thread for answers. Its more test and try what i do.

Im always looking for good code to finish my Controller.

Link to comment
Share on other sites

Why are you typecasting to long? VData.AP is in float so why not leave it this way? If you want to have more control upon the number of decimal places in float try this:

lcd.print(VData.Ap,2);

where 2 is number of decimal places. If you want none, use:

lcd.print(VData.Ap,0);

Also, if you wish I can send you my function I use to format altitudes with proper handling of meters, kilometers, megameters etc. It displays a value and a unit.

I would like to steal your code.

Link to comment
Share on other sites

lcd.print(VData.Ap,2); does not work for me

it shows me a value which i dont know what it is for.

Check the documentation for lcd.print(). The second argument isn't related to decimal places, but sets which base to convert any numbers in the data to.

Why are you typecasting to long? VData.AP is in float so why not leave it this way?

Because Atmel Arduino boards like the Uno and Mega do not have a floating point unit, so any operations on them are done entirely in software and are considerably more expensive. Even better, printf and related functions in the arduino environment do not include support for floating point numbers either. If you want to print apoapsis as kilometres with one decimal point, using the standard Arduino libraries, you need to do something like

char buf[9]; // buffer for formatted string
long i = (long)VData.AP / 1000; // i contains AP in km
long f = (long)VData.AP - (i * 1000); // f contains the fractional part of AP, three digits of precision
f = f / 100; // f contains a single digit of precision
snprintf(buf, 9, "%l.%l", i, f); // format number in buf
lcd.print(buf);

Edited by stibbons
Link to comment
Share on other sites

I would call a text output function in the input file, where it checks for connection:


else
{ //if no message received for a while, go idle
deadtime = now - deadtimeOld;
if (deadtime > IDLETIMER)
{
deadtimeOld = now;
Connected = false;
LEDSAllOff();
[B]//insert AwaitConnectionText() function call here[/B]
}
}

Your actual function will vary depending on what you want to output to. Hope this helps a bit.

Link to comment
Share on other sites

Update 0.17.3

Changed:

Added max overheat (Sputnix request) - byte, reports the overheat percentage of the part mostly likely to explode :D

Added Mach number - float

Added indicated air speed (IAS) - float m/s

Thank you for that Zitronen! :)

I would imagine it would get *far* too problematic to have one for every single part (since there would be n^n parts on any number of space-ships).

I figured it would just be useful for a 'warning' light.

Just to clarify -- does that mean it gives a '43% hot' type value? (as opposed to a dropping 'structural integrity')?

Link to comment
Share on other sites

Thank you for that Zitronen! :)

I would imagine it would get *far* too problematic to have one for every single part (since there would be n^n parts on any number of space-ships).

I figured it would just be useful for a 'warning' light.

Just to clarify -- does that mean it gives a '43% hot' type value? (as opposed to a dropping 'structural integrity')?

Yeah basically it looks at the temperature and max temperature of all the parts and overheat = temperature/maxtemp*100, so 100 = explode. The part with the highest overheat percent (not highest temperature) is reported. You can set a LED warning at 90% overheat or something.

Link to comment
Share on other sites

Yeah basically it looks at the temperature and max temperature of all the parts and overheat = temperature/maxtemp*100, so 100 = explode. The part with the highest overheat percent (not highest temperature) is reported. You can set a LED warning at 90% overheat or something.

Thank you very much for that! :)

Can I also suggest another data point [Assuming it is at all possible]?

CurrentStage //The current (or last) stage fired, as an INT

TotalStage // The Total number of stages in the rocket, as an INT

(I don't think either of these are currently implemented -- at least, I couldn't find them in the list on the first post).

Thanks!

Link to comment
Share on other sites

OK, this is going on the more theoretical aspects of programming, but hopefully someone can give me some pointers.

I want to use the TVout library for an LCD monitor I have lying around. It handles pretty well at 160x120, and is a nice 7" across. However, the TVout library is known to play merry hell with the internal timer in the Arduino, as well as being rather expensive CPU-wise, I want to use a spare UNO as a graphics chip while my Mega handles everything else. As I understand it, TVout uses interrupts, so I cannot be certain the UNO is always paying attention. So I my idea is to use some form of bit banging, with a receipt from the receiver. Would the following pseudocode check out?

Send pin config:

p1 = Write

p2 = Write

p3 = Read


for (int i = 0; i < NumElements; i++)

[INDENT]Set p1 = LOW
while (p3 = HIGH)
[/INDENT]


[INDENT=2]Read p3[/INDENT]

[INDENT]Set p2 = Data[i]
Set p1 = HIGH
while (p3 = LOW)
[/INDENT]


[INDENT=2]Read p3
[/INDENT]

Recv pin config

p1 = Read

p2 = Read

p3 = Write


while i < NumElements

[INDENT]Read p1
If p1 = LOW
[/INDENT]


[INDENT=2]Set p3 = LOW
[/INDENT]

[INDENT]If (p1 = HIGH && p3 = LOW)
[/INDENT]


[INDENT=2]Read p2
Data[i] = p2
Set p3 = HIGH
i++
[/INDENT]

[INDENT]
[/INDENT]


Link to comment
Share on other sites

That pseudocode is pretty much how I understand SPI to work (except for the SS pin). I'd want to try using defined protocols with decent hardware support before trying to write my own bitbanging protocol. If you're especially worried about what TVOut is doing to the timer interrupts, then you might want to try making the display microcontroller the bus master and the serial microcontroller the slave. Check out http://www.gammon.com.au/spi for a good overview of how SPI works.

Link to comment
Share on other sites

Thanks for the suggestion. I already looked into SPI, but unfortunately, SPI uses pin 11. TVout uses that pin as well, and is hardcoded to pins. Someone else tried I2C, but had no luck. The consensus seems to be that TVout is a dirty hack of a library :(

On the positive side, I get to learn how to do port manipulation. Looking on the documentation, I think I might be able to do a 8-bit parallel transfer. The UNO uses four pins for TVout, and the Mega can easily spare an entire port.

Link to comment
Share on other sites

I'm not sure I'd call it dirty, but yeah, it's nudging the limits of what a 16MHz microcontroller can do. Hope you manage to get something good working, a screen would be pretty great.

I'm using a similar model for my panel. Right now I've got a Mega talking to the PC and currently handling the bulk of input. And the display control board I'm designing will have a separate Pro Mini showing data on seven segment displays. I've pretty much settled on using I2C for this. It's not as fast as SPI, but I like the fact a master can broadcast a packet that will be received by all slaves - my code just shunts VesselData packets out over I2C as soon as they arrive, and listeners can act on them as they please.

Link to comment
Share on other sites

Thanks for the suggestion. I already looked into SPI, but unfortunately, SPI uses pin 11. TVout uses that pin as well, and is hardcoded to pins. Someone else tried I2C, but had no luck. The consensus seems to be that TVout is a dirty hack of a library :(

On the positive side, I get to learn how to do port manipulation. Looking on the documentation, I think I might be able to do a 8-bit parallel transfer. The UNO uses four pins for TVout, and the Mega can easily spare an entire port.

I'm still very new to the Arduino; however, I've spoken to people who have paired Arduinos to Raspberry Pi systems for various uses. Given the RP has native video output, would / could that be a possible solution for you? :)

[of course, I'm ignoring budgetary constraints - and just thinking of possible solutions to the problem ;) ]

Link to comment
Share on other sites

Budget is a problem, time is not. I make progress, but it is not exactly fast. I think it is my connection between the boards.

Question: If I connect an input pin on the UNO to an output pin on the Mega, should I add a pull down resistor?

EDIT: Got it working. Still quite slow, though.

EDIT2: Runs at ~ 20 fps. Second field is a counter, everything is debug. It still hangs if the Mega resets, but continues once the Uno is reset.

r0U29t0.jpg?1

:D

Edited by Freshmeat
Link to comment
Share on other sites

If you are just displaying text and simple graphics, you can look at MAX7456 based solutions for composite video. The chip will handle all the video stuff so you don't have to worry about timing. I've been using it for FPV RC flying. You can buy a Minim OSD (MAX7456 + ATMega328) from hobbyking for $10.

Edited by zitronen
Link to comment
Share on other sites

Interesting, but I had the Arduino lying around and a Minim would be either three weeks delivery from China or paying several times the price from here (DK). So I think I'll settle on this.

Besides, it was a learning experience to do a communication protocol. I've never had any education or training in stuff like this, so getting somewhere is half the fun.

Link to comment
Share on other sites

what about 1.0.4?

It works fine? Do you have any problems?

I will have a closer look at the new temperature stuff, but it seems like they kept the things the same just added skin temp, so the warning should still work.

Link to comment
Share on other sites

While brainstorming ideas for alerts to put on my in-progress annunciator panel, I thought it might be nice to be able to detect when an orbit changes SOI. That would make it pretty easy to run simple missions like Mun returns without using the map view at all. But I'm not too sure about good ways to do it.

My only idea so far is to watch for unusual changes in apoapsis. If there's significant change without any throttle, or if it changes a lot more than expected while under throttle, then that's because it's being affected by intercepting another body right? But that feels like a pretty gross kludge. It doesn't work when switching focus to a vessel that's already on an intercept trajectory, and needs some sort of manual intervention to reset.

I'll still give it a try, but can't really test it at the moment because my hardware is in several pieces while I build the enclosure. But am I missing something here? Is there a nicer way to pick up on SOI changes?

Link to comment
Share on other sites

SOINumber is just what SOI you're in now, isn't it? I'd like to set a flag when I'm on a trajectory that intercepts something else. So you'd be able to fly a Mun mission by:

* Achieve LKO.

* Wait until the Mun comes over the horizon.

* Start burning prograde.

* Wait until light on board turns on, indicating orbit now intercepts Mun.

* Stop burning.

* Wait until SOINumber indicates you're now in Mun's SOI.

* Burn to set periapsis.

* Wait until you're at PE.

* Burn retrograde to circularise.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...