there is pastebin link: http://pastebin.com/HYzrTpRs
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
HELP WITH PRESSURE CONTROLLER
Started by RedstonMaster, 06 October 2016 - 05:39 PMPosted 06 October 2016 - 07:39 PM
I have a program in computercraft to control the pressure from pneumatic craft pressure chamber . someone can tell me what's wrong?
there is pastebin link: http://pastebin.com/HYzrTpRs
there is pastebin link: http://pastebin.com/HYzrTpRs
Posted 06 October 2016 - 08:06 PM
What is it doing that you think is wrong and what do you want it to do instead?
Posted 07 October 2016 - 02:11 PM
When I put on the program the monitor doesn't write nothing on the screen , It writes only when preassure is higher
Posted 07 October 2016 - 06:51 PM
Try making a loop where it displays it, run it in a co-routine.
Posted 07 October 2016 - 07:02 PM
A co-routine is overkill for this.Try making a loop where it displays it, run it in a co-routine.
RedstonMaster - the biggest problem I'm seeing in your script is that you set presionActual only once before you start waiting for redstone events and then never check it again. I would recommend adding another check just after the redstone event check - then presionActual will be updated each loop and the program will be able to act accordingly.
...
os.pullEvent("redstone")
presionActual = p.getPressure()
...
Also, you can eliminate the peripheral wrap for the monitor within your loop - that only needs to be done once and you've already done it before the loop.
Posted 08 October 2016 - 01:25 PM
A co-routine is overkill for this.Try making a loop where it displays it, run it in a co-routine.
RedstonMaster - the biggest problem I'm seeing in your script is that you set presionActual only once before you start waiting for redstone events and then never check it again. I would recommend adding another check just after the redstone event check - then presionActual will be updated each loop and the program will be able to act accordingly.... os.pullEvent("redstone") presionActual = p.getPressure() ...
Also, you can eliminate the peripheral wrap for the monitor within your loop - that only needs to be done once and you've already done it before the loop.
Thanks it worked
Edit:
Well it's not working now when I start the program the monitor shows the pression but it don't update the pressure
that's what I did http://pastebin.com/esLsB4W4
Edited on 08 October 2016 - 12:30 PM
Posted 08 October 2016 - 02:33 PM
Are you actually toggling the redstone signal to the computer? This line here:
… will cause it to yield until a redstone signal provided to the system either activates or de-activates.
If you are, then odds are the sleep(1) call is causing the problem - if the state change occurs while the system is sleeping, it won't be able to detect it when you later specifically stop to wait for a redstone event! You'll certainly want to remove that line.
os.pullEvent("redstone")
… will cause it to yield until a redstone signal provided to the system either activates or de-activates.
If you are, then odds are the sleep(1) call is causing the problem - if the state change occurs while the system is sleeping, it won't be able to detect it when you later specifically stop to wait for a redstone event! You'll certainly want to remove that line.
Posted 08 October 2016 - 10:56 PM
Are you actually toggling the redstone signal to the computer? This line here:os.pullEvent("redstone")
… will cause it to yield until a redstone signal provided to the system either activates or de-activates.
If you are, then odds are the sleep(1) call is causing the problem - if the state change occurs while the system is sleeping, it won't be able to detect it when you later specifically stop to wait for a redstone event! You'll certainly want to remove that line.
????????????????????????????????????????????????????????
Posted 08 October 2016 - 11:07 PM
????????????????????????????????????????????????????????
That doesn't really help BombBloke understand which part of the answer you are having issues with.
In simple terms:
While the computer is sleeping, it 'eats events' due to the way sleep functions (it waits for a timer event using iteration, any events caught before that are ignored)
If your redstone state is being toggled while the computer is still sleeping, the `redstone` event fired as a result of the change will be ignored by the sleep function.
You could check if the redstone is in the desired state using `redstone.getInput` straight after the sleep call. If it is not correct, then - and only then `os.pullEvent "redstone"`. Then, if the `redstone` event was fired during the sleep, it doesn't matter because you won't be waiting for one.
It is probably best to remove the unneeded sleep as BombBloke suggested.
Posted 09 October 2016 - 08:19 AM
????????????????????????????????????????????????????????
That doesn't really help BombBloke understand which part of the answer you are having issues with.
In simple terms:
While the computer is sleeping, it 'eats events' due to the way sleep functions (it waits for a timer event using iteration, any events caught before that are ignored)
If your redstone state is being toggled while the computer is still sleeping, the `redstone` event fired as a result of the change will be ignored by the sleep function.
You could check if the redstone is in the desired state using `redstone.getInput` straight after the sleep call. If it is not correct, then - and only then `os.pullEvent "redstone"`. Then, if the `redstone` event was fired during the sleep, it doesn't matter because you won't be waiting for one.
It is probably best to remove the unneeded sleep as BombBloke suggested.
thats what I did http://pastebin.com/Bgu2N777
Posted 09 October 2016 - 08:41 AM
Did you? I still see a sleep function call in there…
Is the issue resolved?
Is the issue resolved?
Edited on 09 October 2016 - 06:44 AM
Posted 09 October 2016 - 08:55 AM
I erased the sleep function but now the monitor only shows pressure while is higher than presiónMaximaDid you? I still see a sleep function call in there…
Is the issue resolved?
I erased the sleep function but now the monitor only shows pressure while is higher than presiónMaxima and I have the issue too long without yieldingDid you? I still see a sleep function call in there…
Is the issue resolved?
Posted 09 October 2016 - 08:57 AM
Too long without yielding is because you have no event yielding. That means os.pullEvent or sleep functions are needed, else your program will loop forever.
What was the problem with the sleep function being used?
What was the problem with the sleep function being used?
Posted 09 October 2016 - 08:58 AM
TOO LONG WITHOUT YIELDING
Posted 09 October 2016 - 09:02 AM
With the sleep command?
Posted 09 October 2016 - 09:15 AM
.
.
sorry for repeating the post
I donn't know :(/>Too long without yielding is because you have no event yielding. That means os.pullEvent or sleep functions are needed, else your program will loop forever.
What was the problem with the sleep function being used?
.
I donn't know :(/>Too long without yielding is because you have no event yielding. That means os.pullEvent or sleep functions are needed, else your program will loop forever.
What was the problem with the sleep function being used?
now the program doesn't work, now the screen is empty.I donn't know :(/>Too long without yielding is because you have no event yielding. That means os.pullEvent or sleep functions are needed, else your program will loop forever.
What was the problem with the sleep function being used?
.I donn't know :(/>Too long without yielding is because you have no event yielding. That means os.pullEvent or sleep functions are needed, else your program will loop forever.
What was the problem with the sleep function being used?
sorry for repeating the post
Posted 09 October 2016 - 09:19 AM
What do you mean, you don't know; What is wrong with the program when the sleep command is used?
Edited on 09 October 2016 - 07:19 AM
Posted 09 October 2016 - 10:19 AM
I don't know that's I did http://pastebin.com/p6yaifwRWhat do you mean, you don't know; What is wrong with the program when the sleep command is used?
Posted 09 October 2016 - 10:56 AM
It doesn't write the pressure in the monitorWhat do you mean, you don't know; What is wrong with the program when the sleep command is used?
Posted 09 October 2016 - 11:02 AM
It does, but you nearly immediately clear it away:
Try it like:
monitor.write(presionActual)
monitor.setCursorPos(1,1)
monitor.clear()
Try it like:
monitor.setCursorPos(1,1)
monitor.clear()
monitor.write(presionActual)
Posted 09 October 2016 - 06:57 PM
now the program is stopped at 0.29912 presureIt does, but you nearly immediately clear it away:monitor.write(presionActual) monitor.setCursorPos(1,1) monitor.clear()
Try it like:monitor.setCursorPos(1,1) monitor.clear() monitor.write(presionActual)
now the program is stopped at 0.29912 presureIt does, but you nearly immediately clear it away:monitor.write(presionActual) monitor.setCursorPos(1,1) monitor.clear()
Try it like:monitor.setCursorPos(1,1) monitor.clear() monitor.write(presionActual)
IT'S WORKING OHHHH YEAH IT'S WORKING :DDDDDDDDDDDD :rolleyes:/> :rolleyes:/> :rolleyes:/> :rolleyes:/> :rolleyes:THAAAAAAAAAAAAAAAAAAAAAAANKS