# E2 rpm

I am looking to build an engine and I am wondering how to make an RPM gauge out of an E2 gate and possibly a gyroscope. What would the code look like? I tried making one and it failed, I didn’t know the proper formula for it. So if anyone has any ideas I would like to see them. Thanks.

Theres an example of an RPM Counter on the wire wiki. http://wiki.garrysmod.com/?title=Wire_Expression2:Examples#RPM_Counter_.28by_Beer.29

That’s good and all but lets say that my input isn’t a wheel, then what would I do?

That works for anything that spins, not just wheel props, but you may have to change :yaw() with pitch() or roll().

I understand that, but lets say that the prop that’s spinning isn’t a wheel, but a square plate instead, what would I do then?

``````

@name RPM
@inputs Wheel:entity
#That just gives it the entity. What you do is get a ent. marker or use the code below.
@outputs RPM
@trigger none
interval(200)
RPM = abs(Wheel:angVel():yaw()/360*60)

``````
``````

@name RPM
@outputs RPM
@trigger none
@persist EE
EE = entity():isWeldedTo
interval(200)
RPM = abs(EE:angVel():yaw()/360*60)

``````

Untested but that should work. For the second one, just weld the chip to the prop you want to measure.

[editline]12:32PM[/editline]

And by the way, wheels don’t have entity outputs.

lol, it doesnt matter if it is a wheel, he named the Variable “Wheel” because it made sense to make it work spawn a wire entity marker from wire - detetction and right click it then the part that you want to get the RPM of then wire Wheel:entity input form the E2 to the entity marker
the E2 will output the RPM of that plate now

@name Tachometer
@inputs Prop:entity
@outputs RPM
@trigger all
interval(100)

RPM = abs(Prop:angVel():yaw()/6)

change :yaw to :roll or :pitch till it works

@name RPM
@outputs RPM
@trigger all
runOnTick(1)
RPM=abs(entity():angVel():yaw()/6)

Yay! One-liners! Place this on the middle of the spinning prop you want the RPM of. Kablammo.

i just posted the same thing

No, see, yours uses an entity input, while mine detects the angular velocity of the E2 chip model itself. Sorry to offend you otherwise.

oh no you weren’t offending me, I forgot to notice it uses the chip instead of an ent

I think this is better:

``````
@name RPM
@outputs RPM
@trigger all
runOnTick(1)
if(first()){E=entity():isWeldedTo()}
RPM=abs(E:angVel():yaw()/6)

``````

Just because you don’t have to worry about placing it in the exact center, and it should eliminate any other errors involving differences between the chip and the wheel, while being just as easy to implement. (Unteseted)

^ Which is mine

Oh, I didn’t look at your second code, sorry. (But the math is still simplified )

Now wait… looking at that, does your code identify the RPM of the prop it is welded to? In that case, I believe my chip would be better, as the orientation of the prop in your chip could mean you would need to change from :yaw to :roll or :pitch. Mine is a tad more user friendly in that respect. Plus the chip should always go in the center of the prop, as to eliminate it flying around at high RPMs. If all that is not the case, rate me a box and I’ll be on my way.

thanks for all the help guys. I’ll try them out tomorrow.

I would use karbines because personaly i don’t like sticking shit to my wheels.

Thats a good point, yours may be more user friendly in that respect.

kp3, the OP was talking about an engine, I’m sure that it wouldn’t be a huge problem to put the chip on one of the engine’s parts. But of course any of these codes would work and its just up to the user’s taste.

neither would have a problem with the e2 being off centre.

Rotational velocity is the same wherever you are on an object.