SHENZHEN I/O

SHENZHEN I/O

Voir les stats:
slx multiple XBus ports?
I I'm guessing there's probably a more efficient way of doing things, but I'm using to MC4ks outputting XBus to 1 MC6k. I can't figure out the slx command to test more than one XBus port.
https://gtm.steamproxy.vip/sharedfiles/filedetails/?id=3076727707

Thanks
< >
Affichage des commentaires 1 à 4 sur 4
mala 9 nov. 2023 à 1h22 
there's no command that allows you to sleep waiting for multiples port at the same time.
While you're waiting for x0, there's no way to know if x1-x2-x3 are trying to transmit something.

there are a couples of tricks you can use when you really need to listen to multiples chips:
1: Link everything to the same xbus (the 2 small chips are both linked to x0 of the big one),
that way you can slx x0, and still wait for one of the chip to transmit. the downside, is that if both chips are transmitting, you only get one value (randomly chosen) and the other will be stuck on "write", so that method is good if only one chip at the time will send signals, and you have no idea which one will.

2: if you're sure that both chips will always transmit at the same time, you could
slx x0
doStuff with x0
slx x1
doStuff with x1
since both chips are transmitting at the same time, everything will happen in the same cycle.

Those method can also be combined, link everything to x0 and just
slx x0
do stuff with first value
slx x0
do stuff with 2nd value

Now, onto your solution, there are a bunch of errors:

never use "slp 1" as first line of code unless specifically requested. By sleeping first, you are skipping the entire 1st cycle, than start performing operation on the 2nd one.
First do your stuff, than sleep to the next cycle (almost always slp will be the last command). On the other hand, slx is almost always used as 1st line, since the chip cycle starts only when it gets called.

probably just a typo, but "point" chip teq p0 100 and if true sends 1 to the big chip. Big chip will test if received value is equal to 100 instead of 1, so it will always be false.

"Foul" chip will send -1, but instructions say that a foul is worth -2.

a chip can easily be connected to multiple ports, check one, perform actions, check 2 perform action, and so on till it goes to sleep. No need of using one chip for every single input/output. Sometime if every input/output can be connected to a single chip, that chip could handle the entire system by itself.
mala 9 nov. 2023 à 6h20 
small addon:
the code i wrote is just to explain how slx could work with multiples ports.
in both examples, if you already know that data is coming from a port you don't have to slx twice to read them.

slx x0
doStuff x0
doStuff x1

also, if you need more than 2 xbus but not that many lines of code, the MC4000X is a better choice than the 6000, smaller and equipped with xbus only
Dernière modification de mala; 9 nov. 2023 à 6h24
Not sure if it's a space issue for you, but why not just connect both "point" and "foul" to the analog ports on the big chip?

Each round check if either one of them has an action required, then do a little nap and do it again next round.

Sure you'll have to power a full cycle when there's nothing to do, but seems efficient enough*.

*I guess you could also have one small chip that listens to both and all it does is send a wakeup to the big chip, I have my doubts you'll get much power efficiency.
Dernière modification de thewifiwhisperer; 10 nov. 2023 à 12h15
Holy Moly!
After 3 days of trying to do it with 2 small chips and 1 big, I was able to do it in 10 lines of code!
Maybe I'll be able to optimize it to save at least 1 line so that I could fit it on an MC4k....

Thanks you two!!
<3
< >
Affichage des commentaires 1 à 4 sur 4
Par page : 1530 50