Jump to content

Project Coding


Dominatus

Recommended Posts

I am currently dabbling in computer coding in order to continue refining a project design I have been working on. This code is supposed to control set enviornmental parameters and maintain a stable internal climate. I just began educating myself on this earlier today, and so have not gotten past instruction in basic commands yet. Even so, I want to know if anyone is interested in taking a look and giving me some pointers. (I don't have entire command or steps finished yet, ditto with set parameters that are currently represented as undefined)

Link to comment
Share on other sites

LOL beat me to it.

You gotta tell us what language you are working in. Are you programming some kind of microcontroller?

Anyway, I started with a college course in C, followed by one in C++ and one in x86 assembly. I've self-taught myself other languages including some scripting languages like Lua and some C#.

Once you understand the basics of coding, you can apply that general knowledge to other computer languages and teach yourself those other languages. You would need to start with a basic, introductory book or course on computer programming. Java, C, and C++ are good, general-purpose computer languages. C++ would probably not be a bad one to start on, but you'd want a learning resource that started out with the assumption that you know nothing about computer programming.

Link to comment
Share on other sites

lua is a great little language that is extremely underrated. it starts out with a plain english syntax that is great for beginners. then you have more complex features like tables, which is probibly one of the most powerful data structures that you ever use. its like arrays, structs, and classes all rolled into one. as an extension to another program its great, but its amazing what you can do in standalone lua. you can roll out complete games and gui applications in no time at all.

you might get a null reference.

Edited by Nuke
Link to comment
Share on other sites

Thanks. I don't know any language per se; like I mentioned, I just started learning and only have basic, very basic commands down. This is supposed to be something like a life support unit with automated features like dehumidifier/ gas collector, air storage, temperature control, irrigation control, etcetera. The "coding" I had done so far was a series of steps in a periodic enviornmental constant evaluation, maintaining a set parameter of humidity, air pressure, temperature and atmospheric composition. The commands are to adjust the various enviornmental components.

Start

Start step: Check Atmos

Check N actual

If undefined > or = N ppm +/- than execute command # (01)

If undefined < or = N ppm +/- than execute command # (02)

End step

Start step: Check O actual

If undefined > or = N ppm +/- than execute command # (03)

If undefined < or = O ppm +/- than execute command # (04)

End step

Start step: check CO2 actual

If undefined > or = CO2 ppm +/- than execute command # (05)

If undefined < or = CO2 ppm +/- than execute command # (06)

End step.

Repeat from Start 2x

End Step: Check atmos

Start: Check pressure

If Variable Psi = undefined Psi (True) than End step

If Variable Psi > Undefined Psi (True) execute command # (07)

If Variable Psi < Undefined (True) execute command # (08)

Repeat step

End step

Start Step: Check humidity

If Variable% = Undefined% +/- (True) End step

If Variable% > Undefined% +/- (True) Execute command # (09)

If Variable% < Undefined% +/- (True) Execute command # (10)

Repeat Step

End step

Start Step: Thermal control

Check temperature

If Variable*C = Undefined*C +/- (True) End step

If Variable*C > Undefined*C +/- (True) Execute command # (11)

If Variable*C < Undefined*C +/- (True) Execute command # (12)

Time Delay 00:30:00

Repeat Step

End Step

Commands List

Command 01: Remove % excess N +/-

Store% excess N +/-

End Command

Command 02: Replenish N

Release% N ppm +/-

Vent% N ppm +/-

Check Variable% N ppm = Undefined% N ppm +/- (True) End command

If Variable% N ppm = Undefined% N ppm +/- (false) Repeat step

End command

(Command 01 is the same as 03 and 05; substitute N with O or CO2)

(Command 02 is the same as 04 and 06; substitute N with O or CO2)

Command 07

Store (Variable) atmosphere = Undefined N, O, CO2 %constant (True)

Command 08

Dispense (Variable) atmosphere = Undefined N, O, CO2 %constant +/- (True)

Command 09 & 10

+/- % humidity = Undefined% +/- (True)

Command 11

Vent Variable*C waste heat

Command 12

Activate thermal heating unit; target temperature +/- Undefined*C

* = degrees

N = Nitrogen

O= Oxygen

CO2= carbon dioxide

Undefined = preset not yet determined: fixed value

Variable = actual value

Ppm = parts per million

I just want to be sure that this is an okay format for the commands to utilize regardless of what language I decide to use/ learn. Does it look okay?

(I've already designed the mechanical components that will go into this project, intellectual property rights claim and such)

Edited by Dominatus
Link to comment
Share on other sites

So you're writing pseudocode? If so, it would make more sense to make it simply human readable. For example:


begin main
if N2_measured >= N2_setting then
remove_excess_N2
else
replenish_N2

if O2 measured >= O2_setting then

. . .

end main

begin remove_excess_N2
store_N2(percentage_amount)
end remove_excess_N2

. . .

Link to comment
Share on other sites

Ah... Okay then. Silly me, really should have done my research prior to writing all if that down. Take one free lesson on basic programming, and suddenly think you know what your doing, am I right? I will research this some more... Learn code and then write it. Yeah, that sounds good...

Link to comment
Share on other sites

Ah... Okay then. Silly me, really should have done my research prior to writing all if that down. Take one free lesson on basic programming, and suddenly think you know what your doing, am I right? I will research this some more... Learn code and then write it. Yeah, that sounds good...

Well, it's not a bad idea to write out your algorithm with pseudocode. That's a time tested solid way of beginning to plan your code out. But there's no reason, if you're writing pseudocode, to use obscure notation. Think of it as making it obvious exactly what your program is going to do to any reader without any need to make it conform to a specific syntax. You've got a great start, actually and with that I don't think you'll have any problem coding the overall structure of your control program. What could be tricky is interfacing all the various subsystems (e.g. How are parameters measured, stored, and/or transmitted to your system. How will you control air release valves, etc?) In my experience, writing the core control code is often the easiest part of a project; interfacing with peripherals is the hard part.

Link to comment
Share on other sites

once you learn one language, learning others is easy. best thing to do is pick a language, figure that out, then learn others as needed. obviously you will want something easy to read, and something with a simple but effective toolchain. ask 10 programmers what to go with and you will get 10 different answers. google various programming languages and find one with a syntax you feel is natural. then start googling tutorials.

Edited by Nuke
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...