Help with a build and programming

I have the original software behaving well after sorting the inconsistencies of design choices and one flat-out error.

You won't need resistors.

You do have to remove the digitalWrites in setup to "close" and "open", they defeat the INPUT_PULLUP lines above it.

The limit switch sense is odd: one pair thinks between limits is a closed switch, the other pair thinks between limits is an open switch.

I simulated the project with those changes in mibd. I used LEDs for the motors, slide switches for the limit switches and NO pushbuttons and was careful about switch sense.

The serial reading responds well to

close#
open#
y#

The pushbuttons start the process they are named for, and the slide switches can be used to stop them when they get there.

It's a bit tricky to operate, use your common sense and ask if you can't get it to close and stop, open and stop with either the pushbuttons or serial input.

See it here

I'll stop working on this copy, any other contributors can run with a copy of it for themselves. I am working to make the entire thing more sensible whilst keeping it as unsophisticated as it is now. It works, you don't care so neither do I.

It is down to getting the wiring right. Once you say you can work the simulation, or if I find remaining errrs to fix, We can go over step by step exactly which switches need NC contacts and which were interpreted as NO, normal in this case meaning NOT at the limit.

I am happy to get this going with you. I am not happy with the code, and you may start to see suggestions and even full solutions coded in a more "correct" manner from other contributors. No worries, we do that all the time. Since you are without the skillz, I advise staying with the code which is now very close to deployable.

If at some point you decide you want to start to be able to do this kind of thing yourself, we here.

I'm not in the lab just now, but I will place comments in the code where I tweaked it when I get the chance.

a7

OK, so I can play with it, just did, and there are a few things that need switching around, but my confidence remains high that with a few label, position or pin changes, it will look and act consistent and correct.

For example open closes and close opens. That kind of mistake. There may be others, for now try to roll with it.

a7

Not now. i have now changed my power supply connections and now have 12v connected into vin that now splits off into the motor controller and aruino, GND is common between the 2 and 5v is a direct link between the 2. Just like this picture.

that is fantastic, and thank you for spending time in looking into my problems.

so from what i can tell what you say is that i was correct in saying something wasnt right and not making sence then? (im not going mad)

i have tried that simulation and have to say that is very clever. i can see how things are meant to work and does look about right to me.

it is quite frustrating for me as i am an electrician by trade and from what i can see and think is that in theory it all looks kind of simple, what with just 2 buttons, 2 motors and 4 limit switches. however and obviously this is slightly harder than just wiring things up to get it going.

i really do appreciate all the help i can get, and if you do manage to iron out the faults and get a working code for me to upload, then i will be eternally grateful and dont mind buying you a pint for your efforts :smiling_face:

if and when you do manage to get something working, then please let me know.

@clambert24 - I have made a new version of the simulation.

The code has been adjusted so all limit switches should be wired between the Arduino pins they are on and ground. All limit switches are NC, that is to say that are closed when the mechanism is not at the limit.

The pushbuttons need to be wired between 5 volts and the Arduino pins they are on, and you'll need a resistor on each as a pulldown. Any value 1K - 10K is fine.

These choices were to minimise any changes to the original sketch, a marvel of a certain kind. If I has written it, I probably wouldn't want to talk about it too much. :expressionless:

It seems the original sketch did not latch the UI buttons. To close the dome, one must hold down the button until. To open, same thing.

If you want the operation to finish on its own, say. It would be easy to latch a short press, in which case I recommend some way other than the limit switches to stop a dome you've sent to one extreme or another.

The ASCOM/RRCI part works, but the get# response is a mystery. Please say if you are using the serial abilities in the sketch. If so, my Serial.print statements need to be removed. And tell me what get# is supposed to report: the current report makes no sense and makes claims beyond what it uses to inform the report can support. Color me curious. Whatever it is meant to do would be easy enough to code.

Use the wokwi for code and wiring.


HTH

a7

HI there.

So just to confirm, they all want to be connected NC? reason I ask is because the 2 open limits are different compared to the closed switches.

See my video for confirmation on what I have got.

Ok I shall find some resistors for the buttons not a problem thank you.

Yes i would like to use ASCOM NINA if possible. I have not setup anything like that just yet though, but would like to try soon. (I may also require help with that :see_no_evil_monkey:)

Im not sure what get# is for either?

Chris.

Open the dome halfway.

Since there is no problem moving either way from halfway open, all limit switches should be conducting.

This will mean picking the contact pair on each switch accordian to how it is sensing the dome.

Each limit switch conducts electricity (is closed) except when its corresponding dome half has reached that switch’s limit.


As for get# and NINA, I don't know much about that side of things TBH. The exist code for serial is straightforward, and this sketch might support enhancements.

I suggest postponing changes and enhancements until you are happy with the pushbuttons and the simple RRCI close#, open# and #y commands.

HTH

a7

ah ok cool not a problem thank you.

i shall download the new sketch file you created and shall give it a go and see how i get on. thank you for helping.

Hi.

I just wanted to say thank you as I now have it working as it should and works great.

Thank you for your help, its much appreciated :clap:

Yay!

If the sketch you are using is different to the last wokwi simulation code, please post it.

The last code has some room for improvement, such work should be done on something that works with your wiring choices.

At the very least, the ugly hack(s) it relies on should be removed for proper fixes.

a7

No its not different, used it as is. I just had a couple of wiring faults ( loose connection and wrong connection on the limit switches, but works great.

Hi, @clambert24
Do you have a DMM?
If not might be worth a purchase of a low cost one.

Tom.... :smiley: :+1: :coffee: :australia:

Dmm?

Hi,
Digital Multimeter.

Tom.... :smiley: :+1: :coffee: :australia:

Oh, lol yeah got one obviously

If you have resolved this topic, please mark it "solved" as another topic on the same subject, but different issue is created.