AJB2K3
Eurobricks Citizen-
Posts
108 -
Joined
-
Last visited
Content Type
Profiles
Forums
Gallery
Everything posted by AJB2K3
-
I had to manually compile and install the NQC tools to get firmware uploaded but once that was done, it all works (well somewhat) and I can now control the Interface B and the RCX from my IDE.
-
Holy Necropsy Batman! Hay Guys, I have put a pause on the cybermaster C2 at the moment to work on the RCX 1.0. I'm trying to make a firmware uploaded but stuck on the first hurdle. I cant get the IR LED to trigger the IR detection icon on my 3 test RCX's Has anyone got a python script for this?
-
Dacta Control Lab Software
AJB2K3 replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
@maehw you want some free software that controls the Interface B on multiple machine like OSX and RPI? https://github.com/Ajb2k3/ULI -
the CM's use the MK2A and 2B 9V motors which are prone to failure and both my modules had a failed motor (thankfully on opposite sides). NO, I think its in command mode 5 flashes instead of 3 after receiving a message but still trying to get the motors running. Triggers acceptance flash but no motors or beeps. import serial import time PORT = '/dev/cu.usbserial-24110' def nqc_force_drive(ser): # The header that is currently giving you 5 flashes header = bytes([0x02, 0x05, 0x00, 0x10, 0xEF, 0x10, 0xEF, 0xFD, 0x03]) sync = bytes([0xA5, 0x5A]) # 1. Set Power B to 7 (22 DD 07 F8) set_pwr = bytes([0x22, 0xDD, 0x07, 0xF8]) # 2. Motor B ON + Forward (21 DE 81 7E) # This is the bitmask that bridges the 7.2V rail to the motor pins. drive_fwd = bytes([0x21, 0xDE, 0x81, 0x7E]) print("--- 5-Flash State Active: Forcing H-Bridge Engagement ---") try: # We flood this to 'latch' the state before the watchdog times out for _ in range(50): ser.write(header + sync + set_pwr + sync + drive_fwd) time.sleep(0.04) except KeyboardInterrupt: pass try: ser = serial.Serial(PORT, 2400, parity=serial.PARITY_ODD, timeout=0.1) nqc_force_drive(ser) ser.close() except Exception as e: print(f"Error: {e}")
-
Update Managed to get the Cybermaster brick's LED to flash with: import serial import time PORT = '' def sweep_channels(ser): # We use the Opcode 0x10 (Battery Poll) because it's proven to work. # We will try Channel 0 (A6), Channel 1 (A7), and Channel 2 (A8). # Math: Length(05) + Sync + Opcode(10) + Op_Comp(EF) + Opcode(10) + Op_Comp(EF) channels = { "Ch 0 (A6)": 0xA6, "Ch 1 (A7)": 0xA7, "Ch 2 (A8)": 0xA8 } for name, sync in channels.items(): # Calculating checksum: (Length + Sync + 10 + EF + 10 + EF) # Note: 10+EF = FF. So: 05 + Sync + FF + FF checksum = (0x05 + sync + 0xFF + 0xFF) & 0xFF packet = bytes([0x02, 0x05, sync, 0x10, 0xEF, 0x10, 0xEF, checksum, 0x03]) print(f"--- Testing {name} ---") print(f"TX: {packet.hex(' ')}") ser.reset_input_buffer() ser.write(packet) time.sleep(0.5) if ser.in_waiting > 0: res = ser.read(ser.in_waiting).hex(' ') print(f"RX: {res}") else: print("RX: [Accepted]") time.sleep(1.0) # Gap to let the Brick reset try: ser = serial.Serial(PORT, 2400, parity=serial.PARITY_ODD, timeout=2) sweep_channels(ser) ser.close() except Exception as e: print(f"Error: {e}")
-
Hmm gemini is loosing patience with this now. import serial import time PORT = '/dev/cu.usbserial-24110' # Update this to your port def send_nqc_style(ser, channel, opcode, data=[]): # 1. Prepare Inner RF Data with Complements # Every byte (opcode, data, and inner sum) is followed by its NOT inner_raw = [opcode] + data inner_sum = sum(inner_raw) & 0xFF rf_body = [] for b in inner_raw + [inner_sum]: rf_body.append(b) rf_body.append(b ^ 0xFF) # Complement # 2. Add Channel (usually not complemented) full_payload = [channel] + rf_body # 3. Calculate Outer Tower Checksum # Tower logic: Sum includes the Length byte + the payload length_byte = len(full_payload) outer_sum = (length_byte + sum(full_payload)) & 0xFF # 4. Construct Final Frame packet = [0x02, length_byte] + full_payload + [outer_sum, 0x03] print(f"\nTX: {bytes(packet).hex(' ')}") ser.write(bytes(packet)) time.sleep(0.6) # Required for RF turnaround if ser.in_waiting > 0: res = ser.read(ser.in_waiting) print(f"RX: {res.hex(' ')}") return res print("RX: [No Response - Brick didn't reply]") return None try: ser = serial.Serial(PORT, 2400, parity=serial.PARITY_ODD, timeout=2) # Critical: The CyberMaster often ignores commands unless a # 'Keep Alive' or 'Link' has been established recently. print("--- Polling Battery (The 'NQC' Way) ---") # Expected TX for Opcode 0x10: 02 05 00 10 ef 10 ef fd 03 send_nqc_style(ser, 0, 0x10) time.sleep(1) print("\n--- Sending Beep ---") # 0x51 is beep, 0x02 is the sound type send_nqc_style(ser, 0, 0x51, [0x02]) ser.close() except Exception as e: print(f"Error: {e}") this python code causes the brick to flash in receiving but the function calls don't work.
-
I changed my adapter, moved back to raw python and sent 0xFE 0x00 0x00 0xFF but got back 0x00 Before on the pl2303 adapter I was just getting b\'' I cant find the opp/bytecodes in NQC, can someone send me the link to them please? I've also loopback tested all my cables and they work, its just sorting out coms.
-
Dacta Control Lab Software
AJB2K3 replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
Yeh, I am aware of that thread and posted a comment. everything I have tried so far has failed so I’m wondering if my adapters can’t do 2400, If the adapters are stuck in 9600 bps. the problem with the CM and Spybotics transmissions could be down to timing and BPS. Oh I just discovered bps is set in the driver, I wonder if that’s my problem that the driver is set to 9600 and overriding the code setting -
Dacta Control Lab Software
AJB2K3 replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
didn't know about WebPBrick, thanks. -
Dacta Control Lab Software
AJB2K3 replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
Hay guys I need some help as im lost getting Cybermaster and Spybotics functions to work can you guys help? I have uploaded a zip file to my GitHub called broken.zip where I'm struggling here. https://github.com/Ajb2k3/ULI -
Dacta Control Lab Software
AJB2K3 replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
Oh i didnt know that. if thats the case then it should be possible to pull something together using an rp2040 of what ever the current version is My current version Availble as as zip on git hub runs on OSX and RPI with no changes. I built it on python to be truly cross compatible. The only difference for the pi is that there is an installation file that neeeds to be run to setup the VM and install the python dependencies -
Dacta Control Lab Software
AJB2K3 replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
Damn typo, sorry. Again typos, I have a scout ordered and in the post. I know the CM came before the RCX Because I brought the CM when it fist came out in the UK but had to wait for the RCX 2.0 to come out to get the RCX 1.0 series. Thanks for your replies. I'm working in OSX so it needs an Arduino to act as an adapter but then the Arduino+interface A will be treated as an Interface B. I never considered direct running from the RPI but again I do believe that the I/O pins were measured @12V so an adapter is still needed (don't have one to varyfy.) I got the Interface B running with a simple python program first, then sorted on the other functions then got board and built the IDE. -
Dacta Control Lab Software
AJB2K3 replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
done -
Dacta Control Lab Software
AJB2K3 replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
I have the full suite of Spybots, RCX 1.0 and 2.0, Cybermaster with a scout on its way but the RCX and cybermaster links are driving me crazy. BTW someone is working on an interface A adapter so I don't want to work on one until he surrenders. My thinking is to get them all working at the same time from a computer like and RP400 or RP500 but I got the interface working with my software on a basic RPI4 -
Dacta Control Lab Software
AJB2K3 replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
Hay call, that's me. I have published an RPI version that supports multiple Interfaces but dont have them to test. I'm trying to add cybermaster and Spybots but no joy. -
Dacta Control Lab Software
AJB2K3 replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
I watched this yesterday, thanks for sharing. I'm planning to control mine over python or Micropython depending on which device I have to had at the time hence why I'm looking at low level I ordered mine from Germany! -
Dacta Control Lab Software
AJB2K3 replied to Dazmundo's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
After running the initial sends to activate and wake up the Interface B I get the following response: b'\x00\x00\xff\xc8\x95L\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xa1' b'\x00\x00\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xb7' b'\x00\x00\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xb7' After that I don't see any changes if I press a button connected to input port 1. Why is the first line b'\x00\x00\xff\xc8\x95L\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xa1' And what is it trying to tell me? OK I got it now but will take a bit to read the data and translate it. Here is the basic python read code: import serial import time ser = serial.Serial(port='/dev/cu.PL2303G-USBtoUART24110') ser.write(b'p\0###Do you byte, when I knock?$$$') #ser.read(16) print(ser.read(31)) ser.flushInput() ser.flushOutput() while True: ser.write(b'2') #time.sleep(1) #ser.read(16) print(ser.read(19)) # Must always be 19 bytes #print(ser.read(2)) ser.flushInput() The following is a sample of the code reading the touch sensor on port 1 '\xcc3\x00\x00\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\x0b@\xff' b'3\x00\x00\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\x0b\x00\xff\xcc' b'\x03\x00\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\x0b\x00\xff\xccs' b'0\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\x0b\x00\xff\xccs\x00' b'\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\x0b@\xff\xcc3\x00\x00' b'\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\x0b\x80\xff\xcc\xf3\x00\x00\xff' b'\xc8\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\x0c\x00\xff\xccr\x00\x00\xff\xc8' b'\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc\x0c\x80\xff\xcc\xf2\x00\x00\xff\xc8\xff' b'\xee\xc8\xff\xcc\xff\xc8\xff\xcc\r\x80\xff\xcc\xf1\x00\x00\xff\xc8\xff\xcc' b'\xc8\xff\xcc\xff\xc8\xff\xcc\x14\xd8\xff\xcc\x92\x00\x00\xff\xc8\xff\xcc\xff' b'\xff\xcc\xff\xc8\xff\xcc\x98\x88\xff\xcc^\x00\x00\xff\xc8\xff\xcc\xff\xc8' b'\xcc\xff\xc8\xff\xcc\xfe\xc8\xff\xcc\xb8\x00\x00\xff\xc8\xff\xcc\xff\xc8\xff' b'\xff\xc8\xff\xcc\xff\x08\xff\xccw\x00\x00\xff\xc8\xff\xcc\xff\xc8\xff\xcc' b'\xc8\xff\xcc\xff\x08\xff\xccw\x00\x00\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff' b'\xff\xcc\xff\x08\xff\xccw\x00\x00\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8' b'\xcc\xffH\xff\xcc7\x00\x00\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff' b'\xf7\xc8\xff\xcc\xb7\x00\x00\xff\xc8\xff\xcc\xff\xc8\xff\xcc\xff\xc8\xff\xcc' -
Technic Pub
AJB2K3 replied to jantjeuh's topic in LEGO Technic, Mindstorms, Model Team and Scale Modeling
I used to moan about the cost of lego sets and then someone showed me a price per piece way to calculate value. Prices have gone up because of part counts have gone up. That saying, the low end of parts per model has gone up. I drink a little Whisky but I've had two beers and a glass of mead and I'm done for the night, I once drunk 1L of saki in 3hours, Now I have a very low alcohol tolerance and get dunk easy.